This page is about building Mogre 1.6 from source code.

These directions have not yet been completely updated for Mogre 1.6. The ((|#Batch_Build|Batch Build)) has been updated, but the ((|#Manual_Build|Manual Build)) has not..

Forum icon info.gif This page is about building the outdated version Mogre 1.6 from source code. For instructions for newer versions, see Building MOGRE from source.

Please follow these steps in the order shown below.

Before we begin

Before we start with the building process, we need to make sure we have met all the requirements:

  • DirectX 9.0c SDK Make sure that DX_DIR envirotment var is set before install DirectSDK.

  • 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. example: C:\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

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:


(Note: If you have built Mogre 1.4 in the past, you would have had a folder called ogrenew with the Ogre3D source code. With this latest revision, the next step is necessary to get a copy of the Ogre source code)

F) Check out a copy of the Ogre source code in the same way as step C, but with these settings:

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 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 more of a single-click process, but it does require that you install and configure a few dependencies:

  • Java (installed and on your PATH) - required for wrapping Ogre with cpp2java
  • 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

If you are using a version of Visual Studio other than 2008, you may need to modify other parts of the script.

Copy this script into a file named install mogre 1.6.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. At a few points during the build, you are required to follow instructions given to you by the script.

:: This script is public domain - Boinst - - October 2009
    @echo off
    title Install Mogre 1.6
    :: 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.      
    :: sz        SevenZip.             
    :: ogredeps  Precompiled Ogre dependencies
    :: dxdir     DirectX SDK           
    :: nsis      NSIS Installer        
    :: patch     patch utility           or
    :: perl      Strawberry Perl       
    set svn="C:\Tools\Svn\svn.exe"
    set sz="C:\Program Files\7-Zip\7z.exe"
    set ogredeps="L:\Applications\Developer\Ogre3D\" 
    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    
    :: vcdir     Visual Studio 2008    
    set vcdir="%VS90COMNTOOLS%..\..\VC"
    set vs08="%VS90COMNTOOLS%..\IDE\"
    :: 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
    :: Final confirmation before executing
    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 correctly installed.
    :: Copy directx libs and headers to the folder where Visual Studio expects to find them.
    :: This step saves us from adding paths to the Mogre 'lib' and 'include' directories.
    copy /Y %dxdir%\Lib\x86\*.lib %vcdir%\lib
    copy /Y %dxdir%\Include\*.h %vcdir%\include
    copy /Y %dxdir%\Include\*.inl %vcdir%\include
    :: check out Mogre 1.6
    %svn% co "Mogre 1.6"
    :: check out Ogre 1.6
    %svn% co "Mogre 1.6\Mogre\Ogre"
    :: Revert any changes to Ogre from previous builds (they would confuse AutoWrap).
    %svn% revert -R "Mogre 1.6\Mogre\Ogre\OgreMain"
    :: Extract Precompiled Dependencies
    %sz% x -o"Mogre 1.6\Mogre\Ogre" -y %ogredeps%
    :: make line endings on the patches consistent. Convert to Windows CRLF
    :: the patch files are actually correct as they are, and Tortoise SVN has
    :: no problem with them, but they cause the 'patch' tool to crash.
    %perl% -pe "s/\n/\n/g" "Mogre 1.6\Mogre\Ogre Patches\CLRObjects.patch" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Ogre Patches\CLRObjects.patch"
    %perl% -pe "s/\n/\n/g" "Mogre 1.6\Mogre\Ogre Patches\Exception.patch" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Ogre Patches\Exception.patch"
    %perl% -pe "s/\n/\n/g" "Mogre 1.6\Mogre\Ogre Patches\OgreMain_vcproj.patch" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Ogre Patches\OgreMain_vcproj.patch"
    :: apply patches
    cd "Mogre 1.6\Mogre\Ogre"
    %patch% -p 0 -i "..\Ogre Patches\CLRObjects.patch"
    %patch% -p 0 -i "..\Ogre Patches\Exception.patch"
    %patch% -p 0 -i "..\Ogre Patches\OgreMain_vcproj.patch"
    del /S /Q *.orig
    cd ..\..\..
    :: copy CLR files
    copy /Y "Mogre 1.6\Mogre\Mogre\Ogre\*.h" "Mogre 1.6\Mogre\Ogre\OgreMain\include"
    copy /Y "Mogre 1.6\Mogre\Mogre\Ogre\*.cpp" "Mogre 1.6\Mogre\Ogre\OgreMain\src"
    :: run cpp2java
    cd "Mogre 1.6\Mogre\cpp2java"
    call doxygen.bat build
    cd ..\..\..
    :: build and execute AutoWrap
    %vs08% /Build "Release|Any CPU" "Mogre 1.6\Mogre\AutoWrap\AutoWrap.sln"
    echo Now we need to run the AutoWrap tool. When you continue, AutoWrap
    echo will launch. Just click 'Produce'. When it's done, you can close
    echo AutoWrap and come back to this script.
    cd "Mogre 1.6\Mogre\AutoWrap\bin\Release"
    cd ..\..\..\..\..
    echo AutoWrap has been launched. Run it before proceeding.
    %perl% -pe "s/copy \$\(InputPath\)/copy \"\$\(InputPath\)\"/g" "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj" 
    :: Build Ogre3D 1.6 (Debug and Release)
    :: First Ogre build - link_to_mogre OFF, remove Mogre.lib references.
    %perl% -pe "s|#define LINK_TO_MOGRE [01]|#define LINK_TO_MOGRE 0|" "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h"
    copy /Y "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h" "Mogre 1.6\Mogre\Ogre\OgreMain\include"
    copy /Y "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj" "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj.backup"
    %perl% -pe "s| Mogre(_d)?.lib||" "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj"
    %vs08% /Build "Debug|Win32" "Mogre 1.6\Mogre\Ogre\Ogre_vc9.sln"
    %vs08% /Build "Release|Win32" "Mogre 1.6\Mogre\Ogre\Ogre_vc9.sln"
    :: Build Mogre
    %vs08% /Build "Debug|Win32" "Mogre 1.6\Mogre\Mogre_vc9.sln"
    %vs08% /Build "Release|Win32" "Mogre 1.6\Mogre\Mogre_vc9.sln"
    :: Second Ogre build - link_to_mogre ON, restore Mogre.lib references.
    %perl% -pe "s|#define LINK_TO_MOGRE [01]|#define LINK_TO_MOGRE 1|" "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h" > tempfile.txt
    move /Y tempfile.txt "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h"
    copy /Y "Mogre 1.6\Mogre\Mogre\Ogre\CLRConfig.h" "Mogre 1.6\Mogre\Ogre\OgreMain\include"
    move /Y "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj.backup" "Mogre 1.6\Mogre\Ogre\OgreMain\scripts\OgreMain_vc9.vcproj"
    %vs08% /Build "Debug|Win32" "Mogre 1.6\Mogre\Ogre\Ogre_vc9.sln"
    %vs08% /Build "Release|Win32" "Mogre 1.6\Mogre\Ogre\Ogre_vc9.sln"
    goto :END
:CheckFileExists ---------------------------------------------------------------
    if not exist %1 call :FileNotFoundError %1
    goto :EOF
:FileNotFoundError -------------------------------------------------------------
    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 ---------------------------------------------------------------------------
: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()
         return UTF_TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) );
         return TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) );    
 void OverlayElement::Caption::set( String^ text )
         DECLARE_NATIVE_UTFSTRING( o_text, text )
         DECLARE_NATIVE_STRING( o_text, text )
         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()
        return UTF_TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption() );
        return TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption( ) );
 void TextAreaOverlayElement::Caption::set( String^ text )
         DECLARE_NATIVE_UTFSTRING( o_text, text )
         DECLARE_NATIVE_STRING( o_text, text )
   static_cast<Ogre::TextAreaOverlayElement*>(_native)->setCaption( o_text);    

C) Thats it! Now you know how Mogre is created.

Alias: Building_MOGRE_1.6_from_source