Compiling Ogre3D V2.1 for dummies

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1140
Joined: Tue Jul 06, 2004 5:57 am
x 15
Contact:

Compiling Ogre3D V2.1 for dummies

Post by spookyboo » Sun Dec 13, 2015 9:50 pm

I've got a new PC and jumped on the 2.1 train. I know that several people already posted some info, but I decided to describe the process step by step. I've added it to the forum and not on the wiki, because I expect that things will change:

Preconditions:
:arrow: Base system is Windows 10
:arrow: Visual Studio Community Free 2015 is used for compilation (64 bit)
:arrow: These instructions only apply to Ogre3D V2.1

DirectX:
If you want to use DirectX in Ogre3D, the 'Windows Software Development Kit (SDK) for Windows 10' is required.
Mandatory for compiling SDL2 however, is the use of the DirectX Software Development Kit 'DirectX 9 SDK (DX SDK June 2010)'; this version is not used by
Ogre3D V2.1 (because it doesn't use DirectX 9 anymore), but it is only used for SDL2 :(
:arrow: 1. Get the Windows Software Development Kit (SDK) for Windows 10 from https://dev.windows.com/en-us/downloads/windows-10-sdk
:arrow: 2. Download 'sdksetup.exe' and install the SDK (this will take some time)
:arrow: 3. Get the DirectX Software Development Kit from https://www.microsoft.com/en-us/downloa ... px?id=6812; this is the 'DirectX 9 SDK (DX SDK June 2010)'
:arrow: 4. Run the downloaded 'DXSDK_Jun10.exe'
:arrow: 5. This results in an error 'Setup failed'. Just ignore it and press 'Finish'.


Get Visual Studio Community Free 2015 and install it:
:arrow: 1. Download 'Visual Studio Community Free' from https://www.visualstudio.com/en-us/down ... io-vs.aspx
:arrow: 2. Run 'vs_community_ENU.exe' (installation takes about half and hour)


Get Ogre 3D V2.1:
The easiest way to download Ogre3D is to grab the zip file directly from Bitbucket.
:arrow: 1. Go to https://bitbucket.org/sinbad/ogre/downloads
:arrow: 2. Select the tab 'Branches'
:arrow: 3. Download branch 'v2-1'
:arrow: 4. This downloads file 'sinbad-ogre-xxxxxxxxxxxx.zip'
:arrow: 5. Create a subdirectory in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects' named 'Ogre2.1'
Use your own name as a replacement for 'LoggedInUser'
:arrow: 6. Extract the zip file (everything in 'sinbad-ogre-xxxxxxxxxxxx') in the directory 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1'
So, do not include 'sinbad-ogre-xxxxxxxxxxxx'.


Get the dependencies:
:arrow: 1. Make a subdirectory in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1' named 'Dependencies'
:arrow: 2. Download the dependencies from 'https://bitbucket.org/cabalistic/ogredeps/downloads'
:arrow: 3. Select the tab 'Branches'
:arrow: 4. Download 'default'; this downloads the file 'cabalistic-ogredeps-zzzzzzzzzzzz.zip'
:arrow: 5. Extract the content of this file in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies'
:arrow: 6. Get SDL from 'https://www.libsdl.org/download-2.0.php'. To be sure, compile it yourself. Download 'SDL2-2.0.3.zip - GPG signed' (this is currently the highest version)
:arrow: 5. Extract the content of this file in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src'
:arrow: 6. Rename the subdir 'SDL2-2.0.3' to 'SDL2' to please CMake
The structure in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\' is:
AMD_Quad_Buffer_SDK_v11
Cg
FreeImage
freetype
NVAPI-R313-developer
ois
SDL2
zlib
zziplib
CMakeLists.txt
Get CMake and install it:
:arrow: 1. Download CMake from https://cmake.org/
:arrow: 2. No 64 bit installer was provided, so the 32 bit version was downloaded (cmake-3.4.1-win32-x86.exe)
:arrow: 3. Install 'cmake-3.4.1-win32-x86.exe'


Compile the dependencies:
:arrow: 1. Start CMake
:arrow: 2. Fill in for 'where is the source code' the path 'C:/Users/LoggedInUser/Documents/Visual Studio 2015/Projects/Ogre2.1/Dependencies'
:arrow: 3. Fill in for 'where to build the binaries' the path 'C:/Users/LoggedInUser/Documents/Visual Studio 2015/Projects/Ogre2.1/Dependencies'
:arrow: 4. Press button 'Configure'
:arrow: 5. Select for 'Specify the generator for this project' the appropriate compiler; in this case it is 'Visual Studio 14 2015 Win 64'
:arrow: 6. Set radiobutton to 'use default native compilers' and press button 'Finish' (if you get errors because it cannot find the compiler (CMAKE_CXX_COMPILER), use 'specify native compilers')
:arrow: 7. Notice that all lines are red. Just press 'Configure' again. The lines are blank now
:arrow: 8. Press button 'Generate'
:arrow: 9. Start 'Visual Studio 2015'
:arrow: 10. Open the solution located in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\OGREDEPS.sln'
:arrow: 11. Build the solution (both Debug and Release, both in x64).
Note, intially the build resulted in '========== Build: 6 succeeded, 2 failed, 0 up-to-date, 0 skipped =========='

One error was:
'CUSTOMBUILD : *** error : DIRECTX requires the $DXSDK_DIR environment variable to be set'.
This can be ignored, and it was because 'Windows Software Development Kit (SDK) for Windows 10' does not set the DXSDK_DIR environment variable.
It was part of 'DirectX 9 SDK (DX SDK June 2010)', which was not installed during the first attempt.

The other error was in freeimage:
'C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1927): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration'
I've updated the file 'tif_config.h' and commented the following lines from line 85:
#ifdef _WIN32
#define snprintf _snprintf
#define lfind _lfind
#endif // _WIN32
This had to be done manually, because an incorrect version of the Dependecies was used; the 'default' branch of the dependencies did not result in this error.
:arrow: 12. OIS_d.dll and OIS.dll are in C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\bin\... When running an Ogre3D sample, this results in an error, because it cannot find the dll files.
For convenience, copy the 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\bin\' directory to 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\bin\src\'

Compile SDL2 separately:
SDL2 is not compiled as part of the compilation of the OGREDEPS.sln solution. Just compile it separately:
:arrow: 1. Start 'Visual Studio 2015' (if not yet started)
:arrow: 2. Open the solution located in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\SDL_VS2013.sln'
:arrow: 3. Visual Studio 2015 automatically upgrades the 2013 solution
:arrow: 4. Build the solution (both Debug and Release, both in x64).


Compile Ogre3D:
:arrow: 1. Start CMake (do not forget to clear the cache by means of File > Delete Cache)
:arrow: 2. Fill in for 'where is the source code' the path 'C:/Users/LoggedInUser/Documents/Visual Studio 2015/Projects/Ogre2.1'
:arrow: 3. Fill in for 'where to build the binaries' the path 'C:/Users/LoggedInUser/Documents/Visual Studio 2015/Projects/Ogre2.1/VCBuild'
:arrow: 4. Press button 'Configure'. Choose for button 'Yes' on the question 'Build directory does not exist; should I create it?'
:arrow: 5. Select for 'Specify the generator for this project' the appropriate compiler; in this case it is 'Visual Studio 14 2015 Win 64'
:arrow: 6. Set radiobutton to 'use default native compilers' and press button 'Finish'
:arrow: 7. Notice that some lines are red and an error is displayed 'error in configuration process; project files may be invalid'. This is because it cannot find SDL2MAIN_LIBRARY, SDL2_INCLUDE_DIR and SDL2_LIBRARY_TEMP

Code: Select all

   Set the following values to these items:
   SDL2MAIN_LIBRARY = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\SDLmain\x64\Release\SDL2main.lib
   SDL2_INCLUDE_DIR = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\include
   SDL2_LIBRARY_TEMP = C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\SDL\x64\Release\SDL2.lib
:arrow: 8. Check 'OGRE_BUILD_SAMPLES2'
:arrow: 9. Uncheck 'OGRE_INSTALL_SAMPLES'
:arrow: 10. Press 'Configure' until all lines are blank
:arrow: 11. Press button 'Generate'
:arrow: 12. Start 'Visual Studio 2015' (if not yet started)
:arrow: 13. Open the solution located in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\VCBuild\OGRE.sln'
:arrow: 14. Build the solution (both Debug and Release, both in x64).

Run Ogre3D:
:arrow: 1. Apparently, SDL2.dll was not copied, so manually copy 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\Dependencies\src\SDL2\VisualC\SDL\x64\Release\SDL2.dll' to
'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\VCBuild\bin\Debug\' and 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\VCBuild\bin\Release\'
:arrow: 2. Run the samples in 'C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1\VCBuild\bin\Release\'
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1202
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 76

Re: Compiling Ogre3D V2.1 for dummies

Post by al2950 » Sun Dec 13, 2015 10:27 pm

@spookyboo
Good job :D
0 x

hyyou
Gremlin
Posts: 166
Joined: Wed Feb 03, 2016 2:24 am
x 6
Contact:

Re: Compiling Ogre3D V2.1 for dummies

Post by hyyou » Tue Apr 05, 2016 9:36 am

Another dummy wants to thank spookyboo. This great article saves me a lot of precious time!

spookyboo's description can be also used for my Windows7. (I skipped Windows10-specific instruction)

I really love the checkpoint at the end of "Get the dependencies", and deep detail about compliation error.
(love you)

I want Ogre samples, so I check "OGRE_INSTALL_SAMPLES" (different from OP's).

As a note to myself and others in future, this is what I do after spookyboo's guide :-
(thank dark_sylinc for review, I have edited it!)

OGRE_HOME=

Code: Select all

C:\Users\LoggedInUser\Documents\Visual Studio 2015\Projects\Ogre2.1

C/C++ > General > Additional Include Directories

Code: Select all

$(OGRE_HOME)\OgreMain\include;$(OGRE_HOME)\VCBuild\include;$(OGRE_HOME)\Dependencies\src\zlib;$(OGRE_HOME)\Dependencies\src\zziplib;$(OGRE_HOME)\Dependencies\src\FreeImage\Source;$(OGRE_HOME)\Dependencies\src\freetype\include\freetype;$(OGRE_HOME)\Dependencies\src\freetype\include;$(OGRE_HOME)\Dependencies\src\ois\includes;$(OGRE_HOME)\Dependencies\src\ois;$(OGRE_HOME)\Dependencies\src\Cg\include;$(OGRE_HOME)\Dependencies\src\Cg;$(OGRE_HOME);$(OGRE_HOME)\OgreMain\include\Threading;$(OGRE_HOME)\Samples\2.0\Common\include;$(OGRE_HOME)\Components\Overlay\include;$(OGRE_HOME)\VCBuild\sdk\include\SDL2;
This is also required if one wish to use HLMS PBS (mainly the include files are OgreHlmsPbs.h & OgreHlmsUnlit.h):-

Code: Select all

$(OGRE_HOME)\Components\Hlms\pbs\include
$(OGRE_HOME)\Components\Hlms\Common\include
$(OGRE_HOME)\Components\Hlms\unlit\include
Linker > General >Additional Library Directory

Code: Select all

left blank
Linker > Input >Additional dependencies
This is for debug mode only :-

Code: Select all

$(OGRE_HOME)\VCBuild\lib\Debug\OgreSamplesCommon_d.lib
$(OGRE_HOME)\VCBuild\lib\Debug\OgreOverlay_d.lib
$(OGRE_HOME)\VCBuild\sdk\lib\SDL2main.lib
$(OGRE_HOME)\VCBuild\sdk\lib\SDL2.lib
$(OGRE_HOME)\VCBuild\lib\Debug\OgreHlmsPbs_d.lib
$(OGRE_HOME)\VCBuild\lib\Debug\OgreHlmsUnlit_d.lib
$(OGRE_HOME)\VCBuild\lib\Debug\OgreMain_d.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\FreeImage\Debug\FreeImage_d.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\zziplib\Debug\zziplib_d.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\zlib\Debug\zlib_d.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\freetype\Debug\freetype_d.lib
This is for release mode only (same as above except : replace all "debug" with "release" and delete all "_d")

Code: Select all

$(OGRE_HOME)\VCBuild\lib\Release\OgreSamplesCommon.lib
$(OGRE_HOME)\VCBuild\lib\Release\OgreOverlay.lib
$(OGRE_HOME)\VCBuild\sdk\lib\SDL2main.lib
$(OGRE_HOME)\VCBuild\sdk\lib\SDL2.lib
$(OGRE_HOME)\VCBuild\lib\Release\OgreHlmsPbs.lib
$(OGRE_HOME)\VCBuild\lib\Release\OgreHlmsUnlit.lib
$(OGRE_HOME)\VCBuild\lib\Release\OgreMain.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\FreeImage\Release\FreeImage.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\zziplib\Release\zziplib.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\zlib\Release\zlib.lib
$(OGRE_HOME)\VCBuild\Dependencies\src\freetype\Release\freetype.lib
This is for both mode (some are related to SDL)

Code: Select all

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;winmm.lib;imm32.lib;version.lib;msimg32.lib;
C/C++ > Preprocessor > Preprocessor definition (release mode only, debug mode don't touch)
If you don't set, in release mode you will face strange SDL2main.lib unresolved external symbol error.

Code: Select all

WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release";
Debugging > Command > (all configurations, edit Jan 2017)

Code: Select all

$(OGRE_HOME)\VCBuild\Bin\$(Configuration)\$(ProjectName).exe
Debugging > Working directory > (all configurations, edit Jan 2017)

Code: Select all

$(OGRE_HOME)\VCBuild\Bin\$(Configuration)
Build Events > Post-Build Event > Command Line (all configurations, edit Jan 2017)

Code: Select all

copy "$(OutDir)$(TargetFileName)" "$(OGRE_HOME)\VCBuild\bin\$(Configuration)"
^ I think all three have to be consistent and point to the "bin" of ogre.
Missing one of these parts will make program run a little, then stop and scream something like "missing brabra.dll/lib"


C/C++ > Preprocessor > Preprocessor definition

I have used Sample_V2Mesh as the template, i.e. mimic them.

In my opinion, scoopydoo's instruction should be added to this wiki page.
I don't dare enough to touch it.
Last edited by hyyou on Thu Apr 06, 2017 11:20 am, edited 15 times in total.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4120
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 245
Contact:

Re: Compiling Ogre3D V2.1 for dummies

Post by dark_sylinc » Wed Apr 06, 2016 6:58 pm

hyyou wrote:If one want to use HLMS, one have to add linker>input>OgreHLMS_d.lib (debug mode),or OgreHLMS.lib (release mode) otherwise will cause "unresolved external symbol"
It sounds you downloaded the Ogre 1.10 branch, because there is no OgreHLMS library in the 2.1 branch. In 2.1 branch the Hlms is part of core. The Unlit and Pbs implementations are provided as libraries though.
0 x

Angramme
Gnoblar
Posts: 2
Joined: Thu Apr 18, 2019 4:46 pm

Re: Compiling Ogre3D V2.1 for dummies

Post by Angramme » Thu Apr 18, 2019 5:52 pm

It's the first time I managed to compile Ogre3D!
Thank you Spookyboo.
One question though, how do I run the samples? my folder looks like this:

Code: Select all

16.04.2019  17:46        12 209 472 cg.dll
18.04.2019  18:37           307 712 OgreHlmsPbs.dll
18.04.2019  18:36            99 328 OgreHlmsPbsMobile.dll
18.04.2019  18:37           124 928 OgreHlmsUnlit.dll
18.04.2019  18:36            77 824 OgreHlmsUnlitMobile.dll
18.04.2019  18:36         7 460 864 OgreMain.dll
18.04.2019  18:37           237 568 OgreMeshLodGenerator.dll
18.04.2019  18:37           286 720 OgreMeshTool.exe
18.04.2019  18:37           769 024 OgreOverlay.dll
18.04.2019  18:31           129 536 OIS.dll
18.04.2019  18:14               299 plugins.cfg
18.04.2019  18:14               115 plugins_tools.cfg
18.04.2019  18:36           152 576 Plugin_ParticleFX.dll
18.04.2019  18:31            46 080 Remotery.dll
18.04.2019  18:37           627 200 RenderSystem_Direct3D11.dll
18.04.2019  18:37           746 496 RenderSystem_GL3Plus.dll
18.04.2019  18:37           141 824 RenderSystem_NULL.dll
18.04.2019  18:14             1 851 resources.cfg
18.04.2019  18:14             1 119 resources2.cfg
18.04.2019  18:14             1 537 samples.cfg
18.04.2019  18:10         1 047 552 SDL2.dll
18.04.2019  18:14                68 tests.cfg
As you can see I only have DLLs and one EXE tool, are the DLLs samples? If yes how do I run them? Thanks in advance for help
0 x

chchwy
Kobold
Posts: 27
Joined: Fri Feb 10, 2017 1:40 am
x 8

Re: Compiling Ogre3D V2.1 for dummies

Post by chchwy » Thu Apr 25, 2019 8:52 am

Angramme wrote:
Thu Apr 18, 2019 5:52 pm
It's the first time I managed to compile Ogre3D!
Thank you Spookyboo.
One question though, how do I run the samples? my folder looks like this:
As you can see I only have DLLs and one EXE tool, are the DLLs samples? If yes how do I run them? Thanks in advance for help
Make sure you check the OGRE_BUILD_SAMPLES2 in CMake
Every sample should be an individual .exe next to Ogre DLLs.
0 x

Post Reply