Principal contributors, Marioko and DodongoXP. Last revised and verified, October, 2009.
This page is about building the outdated version Mogre 1.4 from source code. For instructions for newer versions, see Building MOGRE from source.
Please follow these steps in the order shown below.
Table of contents
Before we begin
Before we start with the building process, we need to make sure we have met all the requirements:
- Visual Studio 2008 Professional or Visual C++ 2008 Express Edition installed.
- DirectX 9.0c SDK Make sure that DX_DIR environment variable is set before installing the Direct SDK.
- The latest Ogre dependencies (currently the Ogre 1.4.8 dependencies) for VS2008 from the Ogre download page on sourceforge.net
- At least 6 gigabytes of hard disk space for the building process
To build the redistributable SDK it is necessary to have installed:
- HM NSIS Edit (optional)
Manual Build
The manual build process uses common GUI tools that many developers will already have installed and configured.
Getting the sources
In this step we need to get a copy of the MOGRE source from MOGRE's project SVN repository. We need to use TortoiseSVN this way:
A) First we create an empty folder somewhere on our hard drive and call it Mogre.
B) Inside that folder right click on blank space, click on SVN Checkout in the context menu and the following window should appear
C) In the field "URL of Repository" write https://mogre.svn.sourceforge.net/svnroot/mogre/branches/1.4
D) Finally click OK and TortoiseSVN will begin downloading the Mogre source code. Wait until the download is complete.
E) When the download has finished you should have a directory called Mogre with all the files inside looking like this:
Compiling OGRE and MOGRE
This is the most important paft of the process of building MOGRE from source. Make sure you did all the required steps as listed before.
Before we begin you need to unzip the OGRE dependencies in the ogrenew folder but DONT OVERWRITE OIS.lib, OIS_d.lib or any other .dll related to OIS. The reason is that MOGRE uses a modified version of OIS and overwriting it with the one in the dependencies would cause severe problems during this process!
A) Open the Mogre_VC9.sln solution which is located in the main folder. This solution include the core of Mogre and related rendering subsystems and Plugins only.
B) Before anything else open the file CLRConfig.h which is inside the OgreMain project and make sure that LINK_TO_MOGRE is set to 0 (zero).
This is necessary because the Mogre.dll file doesn't exist yet.
#define LINK_TO_MOGRE 0
C) Now just build the solution
D) After a successful build, modify the file CLRConfig.h once again and set LINK_TO_MOGRE to 1
#define LINK_TO_MOGRE 1
This time it's only necessary to build (not rebuild, just build it) the OgreMain project. It will relink a couple of libs with MOGRE and it won't take too much to complete.
E) Thats it!! We are done with the process of building MOGRE from source. You will found all generated dll files in MOGRE\bin\ folder
Building the Redistributable SDK
This is the easiest part of the whole process. First make sure you have installed NSIS.
In the folder MOGRE\SDK\ we can find the file buildMogreSDK.bat. Execute it and after a few minutes there should be the installer in the same folder. If the script exits immediately without running, you need to either add the makensis.exe tool to your path, or modify the path to makensis.exe in buildMogreSDK.bat to match the path on your system.
If you want, you can modify any of the installer information by editing the file MogreSDK.nsi in any text editor.
Batch Build
The Batch build is an easy, almost-single-click process, but does require that you have a few dependencies installed.
- Java (installed and on your PATH)
- Subversion - for checking out the source code
- 7zip - for extracting dependencies
- DirectX SDK - required by Ogre
- NSIS - required to build the SDK
- Patch here or here - required to apply patch files.
- Perl - required to modify text files
- Precompiled Ogre Dependencies - required by Ogre
Copy this script into a file named install mogre 1.4.cmd. At the top of the file, there are a few paths that you must set to match your system. Execute the file by double-clicking on it.
:: This script is public domain - Boinst - http://www.streetgeek.com.au/ - October 2009 @echo off cls title Install Mogre 1.4 :: :: Java must be installed and on your path in order to run the cpp2java script used :: to wrap Ogre. :: Visual Studio 2008 must be installed :: :: modify these paths to match your files. If the file or folder specified :: does not exist, an error message will be displayed and the script will :: terminate without modifying your system. :: :: svn Commandline svn. http://subversion.tigris.org/getting.html#windows :: sz SevenZip. http://www.7-zip.org/ :: ogredeps Precompiled Ogre dependencies http://www.ogre3d.org/download/source :: dxdir DirectX SDK http://www.microsoft.com/downloads/details.aspx?FamilyID=b66e14b8-8505-4b17-bf80-edb2df5abad4 :: nsis NSIS Installer http://nsis.sourceforge.net/Download :: patch patch utility http://sourceforge.net/projects/unxutils/ or http://gnuwin32.sourceforge.net/packages/patch.htm :: perl Strawberry Perl http://strawberryperl.com/releases.html :: set svn="C:\Tools\Svn\svn.exe" set sz="C:\Program Files\7-Zip\7z.exe" set ogredeps="L:\Applications\Developer\Ogre3D\OgreDependencies_VC9_Eihort_20080203.zip" set dxdir="C:\Program Files (x86)\Microsoft DirectX SDK (August 2009)" set nsis="%ProgramFiles(x86)%\NSIS\makensis.exe" set patch="C:\Tools\UnxUtils\patch.exe" set perl="C:\strawberry\perl\bin\perl.exe" :: :: The next few paths are set by Visual Studio when it is correctly installed, you :: shouldn't need to modify them :: :: vs08 Visual Studio 2008 http://www.microsoft.com/exPress/download/ :: vcdir Visual Studio 2008 http://www.microsoft.com/exPress/download/ :: set vcdir="%VS90COMNTOOLS%..\..\VC" set vs08="%VS90COMNTOOLS%..\IDE\devenv.com" :: check for files set ERRORLEVEL=0 call :CheckFileExists %svn% call :CheckFileExists %sz% call :CheckFileExists %ogredeps% call :CheckFileExists %vs08% call :CheckFileExists %dxdir% call :CheckFileExists %vcdir% call :CheckFileExists %perl% call :CheckFileExists %nsis% call :CheckFileExists %patch% if not %ERRORLEVEL% == 0 goto :END :: go to 'Source Code' folder echo Executing Mogre 1.4 installation script in "%CD%" echo Mogre and its dependencies will be checked out in subfolders echo All dependencies appear to be installed. pause :: copy directx libs and headers copy /Y %dxdir%\Lib\x86\*.lib %vcdir%\lib copy /Y %dxdir%\Include\*.h %vcdir%\include copy /Y %dxdir%\Include\*.inl %vcdir%\include echo Checking out source code :: check out Mogre 1.4 %svn% co https://mogre.svn.sourceforge.net/svnroot/mogre/branches/1.4 "Mogre 1.4" :: unzip dependencies %sz% x -o"Mogre 1.4\Mogre\ogrenew" -y %ogredeps% :: Build Ogre3D 1.4 :: set flags for first compile. Turn OFF link_to_mogre. echo Building Ogre3D 1.4 and Mogre 1.4 %perl% -pe "s|#define LINK_TO_MOGRE [01]|#define LINK_TO_MOGRE 0|" "Mogre 1.4\Mogre\ogrenew\OgreMain\include\CLRConfig.h" > tempfile.txt move /Y tempfile.txt "Mogre 1.4\Mogre\ogrenew\OgreMain\include\CLRConfig.h" %vs08% /Build "Debug|Win32" "D:\Source Code\Mogre 1.4\Mogre\Mogre_vc9.sln" %vs08% /Build "Release|Win32" "D:\Source Code\Mogre 1.4\Mogre\Mogre_vc9.sln" :: set flags for second compile. Turn ON link_to_mogre. %perl% -pe "s|#define LINK_TO_MOGRE [01]|#define LINK_TO_MOGRE 1|" "Mogre 1.4\Mogre\ogrenew\OgreMain\include\CLRConfig.h" > tempfile.txt move /Y tempfile.txt "Mogre 1.4\Mogre\ogrenew\OgreMain\include\CLRConfig.h" %vs08% /Build "Debug|Win32" "D:\Source Code\Mogre 1.4\Mogre\Mogre_vc9.sln" %vs08% /Build "Release|Win32" "D:\Source Code\Mogre 1.4\Mogre\Mogre_vc9.sln" :: build Mogre 1.4 SDK echo Building Mogre 1.4 SDK cd "Mogre 1.4\Mogre\SDK" %nsis% MogreSDK.nsi cd ..\..\.. goto :END :CheckFileExists --------------------------------------------------------------- if not exist %1 call :FileNotFoundError %1 goto :EOF :FileNotFoundError ------------------------------------------------------------- echo. set ERRORLEVEL=1 if '%1' == '' ( echo A required file or directory was not found. ) if not '%1' == '' ( echo File or Directory not found: %1. Install the prerequisite, or modify the path to match your system. ) goto :EOF :END --------------------------------------------------------------------------- pause :EOF ---------------------------------------------------------------------------
Additional Info
If someday you ask yourself how is OGRE wrapped then you need read this addional info. Mogre is created using an autowrapper tool that can convert all Ogre native headers code to C++/CLI managed code, all generated source files are in MOGRE\Mogre\include\auto and MOGRE\Mogre\src\auto folders. You can use this autowrapper following the next steps.
Wrapping OGRE
To wrap OGRE you need the following tools: cpp2java created by the programmers of Ogre4j and AutoWrap created by Argiris Kirtzidis alias Bekas to create MOGRE.
A brief introduction to these tools:
cpp2java: this is an excellent XSL stylesheet invoked by an ant script which uses doxygen to create an xml file with all the structure of the ogre headers or any other c++ project, the resulting meta.xml file can be used to easily create wrappers to other languages like ogre4j and mogre, as cpp2java uses java applications (ant and saxon as XSLT processor) you need to have the JRE (Java Runtime) installed on your pc to run it.
AutoWrap. created by our friend bekas it's an amazing tool which uses the meta.xml generated by cpp2java to automatically create all the required .h and .cpp files which encapsulate OGRE.
With the appropriate modifications made, this tool can be used to create wrappers for other projects besides OGRE or even to make wrappers for the OGRE addons (nxogre, plsm, paged geometry and so on).
All right, let's start:
A) In the directory cpp2java should be a file called build.bat. If you have the JRE succesfully installed we will only need to execute this file.
B) At the cpp2java folder we will find a directory called "build" which has the following files inside:
C) Now we need to compile AutoWrap, which is in the autowrapp directory inside the Mogre directory. Open the VC# solution called autowrap.sln and build it, then run it and you should see this window:
D) This is an application with a very simple interface but very powerful. Here we only need to click on the "Produce" button. If you want to see the code that will be generated you can click on a file on the list.
E) If this message appears everything went ok. You can check by looking at the folders Mogre/Mogre/include/auto/ and Mogre/Mogre/src/auto/
Adding Unicode Support
The current version of AutoWrap will not automatically generate support for unicode text in the overlays, therefore it is necessary to do it manually.
The procedure is very simple:
A) In the MogreOverlayElement.cpp file that generates AutoWrap which should be in the folder src\auto of MOGRE it is needed that the Caption property is modified like this :
//Public Declarations String^ OverlayElement::Caption::get() { #ifdef OGRE_UNICODE_SUPPORT return UTF_TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) ); #else return TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) ); #endif } void OverlayElement::Caption::set( String^ text ) { #ifdef OGRE_UNICODE_SUPPORT DECLARE_NATIVE_UTFSTRING( o_text, text ) #else DECLARE_NATIVE_STRING( o_text, text ) #endif static_cast<Ogre::OverlayElement*>(_native)->setCaption( o_text ); }
B) We do the same thing with the file MogreTextAreaOverlayElement.cpp which should be in the same folder as the previous file.
String^ TextAreaOverlayElement::Caption::get() { #ifdef OGRE_UNICODE_SUPPORT return UTF_TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption() ); #else return TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption( ) ); #endif } void TextAreaOverlayElement::Caption::set( String^ text ) { #ifdef OGRE_UNICODE_SUPPORT DECLARE_NATIVE_UTFSTRING( o_text, text ) #else DECLARE_NATIVE_STRING( o_text, text ) #endif static_cast<Ogre::TextAreaOverlayElement*>(_native)->setCaption( o_text); }
C) Thats it! Now you know how Mogre is created.