Principal contributors, Marioko and DodongoXP. Last revised and verified, October, 2009.

Forum icon info.gif 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.

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 environment variable is set before installing the Direct SDK.

  • 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

Image

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.

Image

E) When the download has finished you should have a directory called Mogre with all the files inside looking like this:

BuildingMogreNew3.gif

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:

BuildingMogre7.gif

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:

BuildingMogre8.gif

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.

BuildingMogre9.gif

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.


Alias: Building_MOGRE_1.4_from_source

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.