OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Building MOGRE 1.6 from source
View page
Source of version: 11
(current)
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.''. {img src="img/wiki_up/Forum_icon_info.gif" alt="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. {maketoc} !!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 [http://www.microsoft.com/express/vc/Default.aspx|Visual C++ 2008 Express Edition] installed. * [http://www.microsoft.com/downloads/details.aspx?FamilyID=4b78a58a-e672-4b83-a28e-72b5e93bd60a&DisplayLang=en|DirectX 9.0c SDK] Make sure that DX_DIR envirotment var is set before install DirectSDK. * [http://tortoisesvn.net|Tortoise SVN] * [http://downloads.sourceforge.net/ogre/OgreDependencies_VC8SP1_Eihort_20071227.zip|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: * [http://nsis.sourceforge.net/Main_Page|NSIS Nullsoft Installer System] * 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'' ~np~B)~/np~ Inside that folder right click on blank space, click on SVN Checkout in the context menu and the following window should appear {img src="img/wiki_up/BuildingMogre1.gif" alt="" width="400"} C) In the field "URL of Repository" write {MONO()}~np~https://mogre.svn.sourceforge.net/svnroot/mogre/tags/MOGRE-1.6.5/~/np~{MONO} D) Finally click OK and TortoiseSVN will begin downloading the Mogre source code. Wait until the download is complete. {img src="img/wiki_up/BuildingMogre2.gif" alt="" width="400"} E) When the download has finished you should have a directory called Mogre with all the files inside looking like this: {img src="img/wiki_up/BuildingMogreNew3.gif" alt="BuildingMogreNew3.gif"} (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: * URL of Repository: __[https://ogre.svn.sourceforge.net/svnroot/ogre/branches/v1-6]__ * Destination Folder: __Ogre__, such that ''Mogre'' and ''Ogre'' are subfolders of the same parent directory. ''example: C:\Ogre'' !!!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. ~np~B)~/np~ 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. {MONO()}#define LINK_TO_MOGRE 0{MONO} 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 {MONO()}#define LINK_TO_MOGRE 1{MONO} 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: * [http://www.java.com/download|Java] (installed and on your PATH) - required for wrapping Ogre with cpp2java * [http://subversion.tigris.org/getting.html#windows|Subversion] - for checking out the source code * [http://www.7-zip.org/|7zip] - for extracting dependencies * [http://www.microsoft.com/downloads/details.aspx?FamilyID=b66e14b8-8505-4b17-bf80-edb2df5abad4|DirectX SDK] - required by Ogre * [http://nsis.sourceforge.net/Download|NSIS] - required to build the SDK * Patch [http://sourceforge.net/projects/unxutils/|here] or [http://gnuwin32.sourceforge.net/packages/patch.htm|here] - required to apply patch files. * [http://strawberryperl.com/releases.html|Perl] - required to modify text files * Precompiled [http://www.ogre3d.org/download/source|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. {CODE(wrap="1", colors="winbatch")} :: This script is public domain - Boinst - http://www.streetgeek.com.au/ - October 2009 @echo off cls 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. 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 :: 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. pause :: 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 https://mogre.svn.sourceforge.net/svnroot/mogre/trunk "Mogre 1.6" :: check out Ogre 1.6 %svn% co https://ogre.svn.sourceforge.net/svnroot/ogre/branches/v1-6 "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. 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. echo. @pause cd "Mogre 1.6\Mogre\AutoWrap\bin\Release" AutoWrap.exe cd ..\..\..\..\.. echo. echo AutoWrap has been launched. Run it before proceeding. echo. @pause %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 ------------------------------------------------------------- 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 ---------------------------------------------------------------------------{CODE} !!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. ~np~B)~/np~ At the cpp2java folder we will find a directory called "build" which has the following files inside: {img src="img/wiki_up/BuildingMogre7.gif" alt="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: {img src="img/wiki_up/BuildingMogre8.gif" alt="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. {img src="img/wiki_up/BuildingMogre9.gif" alt="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 : {CODE(wrap="1", colors="c++")} //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 ); }{CODE} ~np~B)~/np~ We do the same thing with the file __MogreTextAreaOverlayElement.cpp__ which should be in the same folder as the previous file. {CODE(wrap="1", colors="c++")} 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); }{CODE} C) Thats it! Now you know how Mogre is created. --- Alias: (alias(Building_MOGRE_1.6_from_source))
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
8 online users