Skip to content

Latest commit

 

History

History
253 lines (192 loc) · 11.2 KB

BuildingVS.md

File metadata and controls

253 lines (192 loc) · 11.2 KB

About

This page describes how to compile Stunt Rally 3:

  • on Windows (10 only tested)
  • buiding first all dependencies from sources
  • using VS 2019
    Could be older but seems that newer versions aren't yet tested for Ogre-Next at least.
    There is a free Visual Studio Community edition here, it should work okay (didn't check)
    (Visual Studio is a big commercial solution though, way too big and bloated)

Surely this is a long and somewhat tedious process, it can take 2 hours or more to complete ⚠️.

SR3 depends on Ogre-Next 3.0, and MyGui fork for it which aren't released or packaged at all.
Other alternative could be getting Conan to work, or vcpkg. This is not done for SR3 (WIP PR here).

An easier project to build is my ogre3ter-demo it only uses Ogre-Next.

1. Getting Dependencies

We need tools: Git and CMake installed.

This table lists all needed dependencies (libraries) for SR3:

Library Version used Website Downloads
tinyxml2 9.0.0 https://github.com/leethomason/tinyxml2/ Downloads
Bullet 3.25 https://pybullet.org/wordpress/ Downloads
Boost 1.81 https://www.boost.org Downloads
Enet 1.3.17 https://enet.bespin.org Downloads
Ogg 1.3.5 https://xiph.org Downloads
Vorbis 1.3.7 https://xiph.org Downloads
OpenAL Soft 1.23.1 https://github.com/kcat/openal-soft tags
Ogre-Next
has SDL2
3.0 https://www.ogre3d.org git repo not to Download, script
MyGui-next 3.? http://mygui.info/ git repo

Newer, latest versions can be used.
Only Ogre-Next and MyGui-next are special cases, info in own, later sections.

2. Building dependencies

2.1

Ogre-Next soruces are downloaded (using Git) by a script, which will also get its dependencies like SDL2 and build them and itself.
MyGui-next is my fork, it needs downloaded .zip with sources or cloned by Git.
Both are explained later, for now no need to do anything.

2.2

For Boost, since I used VS 2019 14.2 (upgrade 2, not 3 yet) I downloaded boost_1_81_0-msvc-14.2-64.exe to match it.
For me this e.g. 14.2 is shown in VS Installer app on tab Individual components as: C++ Modules for v142 build tools (x64/x86)
and are present and picked in Project properties, in General tab, Platform Toolset.
This is an .exe that will extract Boost files to a typed folder.

2.3

Bullet is different, it has a file build_visual_studio_vr_pybullet_double_dynamic.bat.
Important line in this .bat is starting with: premake4 --dynamic-runtime --double
Meaning bullet will use double types and dynamic DLL for runtime.
I recommend removing --double from it, it's not needed and works slower on old PCs.

Start this .bat file, it that will generate a folder bullet3\vs2010\ with 0_Bullet3Solution.sln file,
open it and build with your VS (first convert dialog will show).
You can build whole solution, there is more stuff.
We definitely need to build: BulletCollision, BulletDynamics, BulletFileLoader, BulletWorldImporter, LinearMath.
Those are older bullet 2 libs (bt* names), not the bullet 3 new (b3* names).

2.4

The rest: tinyxml2, Enet, Ogg, Vorbis, OpenAL Soft, for each:
download .zip file with sources for latest stable release version and extract in root folder e.g. c:\dev
Resulting in e.g. these dirs:

c:\dev\
  bullet3-3.25
  enet-1.3.17
  libogg-1.3.5
  libvorbis-1.3.7
  openal-soft-1.23.1
  tinyxml2-9.0.0

These libs have CMakeLists.txt file inside, which means we need to:
for each lib: start CMake-Gui, pick sources folder to where you extracted it
e.g. c:\dev\enet-1.3.17, and then new build folder inside e.g. to c:\dev\enet-1.3.17\build
After that set, press Configure, twice, and lastly Generate.
Now there should be a .sln file inside build\ dir.

Open it (with your VS) and build solution.
We need to build Release x64 (64 bit compiler, Release configuration), later if needed Debug for any issue finding.

Many of these libraries will build just as Static library .lib. That's okay, these will link with our exe, not be in own DLL.

For enet also these system libs were needed to add in Properties - Linker input:
winmm.lib;Ws2_32.lib;

Very important thing is that all should use in:
Project Properties - C++ - Code Generation - Runtime Library: Multi Threaded DLL, and for Debug same but with Debug DLL.
This was set so in all but best to be sure. Failing that would lead to many linker issues much later when linking SR3.

3. Building Ogre-Next

Building Ogre-Next from sources, using scripts.

Save the file build_ogre_Visual_Studio_16_2019_x64.bat
and put it inside our root folder c:\dev

We need Ogre-Next branch v3.0 now. So edit build_ogre_Visual_Studio_16_2019_x64.bat and replace in this top line:
set OGRE_BRANCH_NAME=master" to set OGRE_BRANCH_NAME=v3-0 and save file.

Also in same file we have to add -D OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS=1 in 2 lines starting with cmake -D ...
So they should start like:
cmake -D OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS=1 ...

Then open cmd and start the .bat.

This should succeed after a longer while and build Ogre-Next with its dependencies.

If so you can start and check Ogre demos and samples inside:
c:\dev\Ogre\ogre-next\build\bin\Release\
It's good to check if they work before continuing.

3.1 (Optional) Ogre components, rebuild

  • Now not needed, optional step. We need to have below 2 components built with Ogre.

    In c:\dev\Ogre\ogre-next\build\
    edit the file CMakeCache.txt and be sure the lines:

    OGRE_BUILD_COMPONENT_ATMOSPHERE:BOOL=ON
    ...
    OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS:BOOL=ON
    

    have ON at end. At least PLANAR_REFLECTIONS is not by default.

  • Now build Ogre again. So, in all needed configurations, by opening solution
    OGRE-Next.sln from above build\ dir, and building in VS.
    This will take less time than first in cmd.


  • Optional note.
    This (rebuild Ogre) step is also needed, after updating Ogre sources to latest (git pull in Ogre/ogre-next/).
    Caution: if this was done later, after building MyGui and/or StuntRally3,
    then you need to rebuild also MyGui and then StuntRally3 too.

  • Optional for Debug only.
    For Debug build to be usable we have to comment out this assert,
    (needs rebuilding Ogre-Next after),
    I added // at start in OgreNode.h (line was 681, could change):

        virtual_l2 FORCEINLINE const Matrix4 &_getFullTransform() const
        {
#if OGRE_DEBUG_MODE >= OGRE_DEBUG_MEDIUM
            //assert( !mCachedTransformOutOfDate );
#endif

4. Building MyGui-Next

MyGui-Next is my fork of MyGui on branch ogre3.
I follow its build guide here.
It isn't the latest, and was also based on fork.

No need to set, it is so by default:

  • MYGUI_RENDERSYSTEM: 8 - Ogre 3.x
  • MYGUI_USE_FREETYPE: yes
  • all MYGUI_BUILD*: no
  • MYGUI_STATIC: no, MYGUI_DONT_USE_OBSOLETE: no

You could donwload .zip with sources, but git clone is better,
since you can later do git pull to get any updates.

Inside c:\dev\

git clone https://github.com/cryham/mygui-next --branch ogre3 --single-branch

Follow its build guide here.
This needs renaming few cmake files in it.

Open CMake-Gui, pick sources c:\dev\mygui-next, build to c:\dev\mygui-next\build.
Press Configure twice, then Generate.

We need Release build, only if Release fails, then Debug too.

6. Clone SR3

Clone SR3 (this repo) and SR3 tracks inside data/tracks:
In c:\dev\

git clone https://github.com/stuntrally/stuntrally3.git sr3
cd sr3/data
git clone https://github.com/stuntrally/tracks3.git tracks

7. Build SR3

Rename the files, replacing them (best to keep copies):
CMakeLists-WindowsRelease.txt to:
CMakeLists.txt
and
\bin\Release\plugins_Windows.cfg to:
\bin\Release\plugins.cfg

Open CMake-Gui, pick sources c:\dev\sr3 and build as c:\dev\sr3\build.

If doing a Debug build, then do same but use: CMakeLists-WindowsDebug.txt and
bin\Debug\plugins_Windows.cfg
and choose a different build dir e.g. c:\dev\sr3\buildDebug

Press Configure twice.
If it fails, then probably need to adjust some paths in CMake files.
If it succeeded then press Generate.
Open c:\dev\sr3\build\StuntRally3.sln with VS (2019),
pick Release x64 configuration and build it.

This should produce valid *.exe files

8. Start StuntRally3

Copy into c:\dev\sr3\bin\Release\
all needed *.dll files from previously built dependencies, we need:

MyGUIEngine.dll
OgreHlmsPbs.dll
OgreHlmsUnlit.dll
OgreMain.dll
OgreOverlay.dll
OgrePlanarReflections.dll
OpenAL32.dll
Plugin_ParticleFX.dll
RenderSystem_Direct3D11.dll (not used yet)
RenderSystem_GL3Plus.dll
SDL2.dll
amd_ags_x64.dll (got from internet)

If build succeeded, start:
c:\dev\sr3\bin\Release\StuntRally3.exe - for SR3 game
c:\dev\sr3\bin\Release\SR-Editor3.exe - for SR3 Track Editor
and if for Debug then inside:
c:\dev\sr3\bin\Debug

Starting any .exe with cfg argument will show Ogre config dialog.

If Ogre dialogs shows empty, replace plugins.cfg with plugins_Windows.cfg again.

Only Open GL 3+ Rendering Subsystem should be used (DX11 fails).

Logs will be in:
C:\Users\USERNAME\AppData\Roaming\stuntrally3\