Building From Source - Windows - Shoggoth         Building Ogre from source on the Windows platform

%prevogre%

MS Visual C++

Prerequisites

Development Environment Specific Dependencies

The Ogre team offers full support for Visual C++ 2008 (all editions including Express).

Tip_icon.png You need to install Service Pack 1 for Visual Studio 2008 - and the ATL security fix as well (available through Microsoft Update).


Dependencies
The precompiled dependencies is available here.
The dependencies work with both the current stable branch (Shoggoth, or 1.6) as well as SVN HEAD (Ogre 1.7 a.k.a. Cthugha).

DirectX SDK

Download the latest DirectX 9.0 SDK from http://msdn.microsoft.com/directx.

The DirectX SDK install should automatically update the Visual Studio include and library paths with the locations of the DX SDK includes and lib paths. If not, you will need to enter the DirectX include and library directories into MSVC so you can compile against the SDK. It would look something like this:

  • Select Tools|Options|Projects|VC++ Directories

Info Path to the folder must be ON TOP of the list or you will get errors during compilation (Example: error LNK2001: unresolved external symbol _IID_IDirect3DBaseTexture9)

  • Under library files, set the appropriate library directory for the SDK. E.g.,

C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86

  • Under include files, set the appropriate include directory for the SDK. E.g.,

C:\Program Files\Microsoft DirectX SDK (August 2007)\Include

Ogre Source

  • Go to http://www.ogre3d.org and select, More Downloads, then Source: Windows. Alternately, you can get the source from SVN, using the instructions at http://www.ogre3d.org/index.php?option=com_content&task=view&id=415&Itemid=144. The current stable branch is titled "+v1"6+".
  • Extract the Ogre source (if you downloaded a source tarball).
  • Regardless of how you obtained the source, you will then need to extract the Dependencies inside the ogre folder (so that you end up with an ogre/Dependencies folder).


If for whatever reason you want to build dependencies yourself (e.g. you're using the unstable version and precompiled dependencies aren't available), see the Building Dependencies page.

Building

With the prerequisites installed, we are ready to build OGRE.

  • Open the ogre\ogre.sln file (ogre\Ogre_vc8.sln for VC++ 2005 and VC++ 2008, all editions; VC++ 2008 will convert the solution and projects for you)
  • Click "build all".


The build process takes around 15 minutes on a modern P4 class system. If all goes well, the engine, plugins, tools, and demos will build.

Next, try running the demos to verify everything worked. They are found in ogre\Samples\Common\bin\Debug (or bin\Release if built in release mode).

Project Setup

If you are using VC++ .NET 2003 or later, you can use the Ogre Application Wizard and you are ready to create OGRE apps. See also The Complete Blanks Guide To Using The OGRE SDK AppWizard - Shoggoth.

If you feel like setting up a project manually, heres how:

Provided with OGRE is a subclassable ExampleApplication class (found in ogre\Samples\Common\include, just for future reference), which will allow you to develop applications very quickly using a fairly standard set of parameters. While OGRE will allow you to build most any kind of application you wish, the ExampleApplication will provide you with a good base for the majority of 3D applications, and is even suitable for building production-level apps off of.

We'll start by setting up a new Visual C++ Win32 project.

Make sure that "Empty Project" is checked in the application settings. I like to create my smaller projects in the ogre\Samples directory, simply for consistency's sake. You can put them wherever you like, however.

Once you have your project, the first thing you're going to want to do is set up your project properties to use OGRE. There is a tutorial on doing this here (http://www.ogre3d.org/wiki/index.php/SettingUpAnApplication). The tutorial will also walk you through the basics of setting up an app, so feel free to browse through it. However, if you just want the quick rundown, here's what you'll need to do:

  • Right-click the project name in the solution explorer and select "Properties".
  • Add the ogre\OgreMain\include and ogre\Samples\Common\include directories to your "additional includes" directory (Found under C++/General). Visual Studio requires you to create a .cpp or .h file for the C++ options to show up.
  • Add ogre\OgreMain\lib\(Debug|Release) to your "library search paths" field (found under Linker/General)
  • Add OgreMain.lib to the "Additional Dependencies" field (found under Linker/Input)


(Note - if you've downloaded the libraries from the Ogre website and are using the Debug ones you will need to make this OgreMain_d.lib — not adding the _d will cause ~4 perplexing linker errors. Hope this helps anyone in need. --lurkingfridge79)

  • Under C++/Code Generation, change "Runtime Library" to "Multi-threaded Debug DLL" (for debug-mode apps) and "Multi-threaded DLL" (For release-mode apps).


It is also recommended that you change your "Output Directory" (under General) and your "Working Directory" (under Debugging) to the ogre\Samples\Common\bin\(Debug|Release) directory. This will place the file in the same directory as the already-existing OGRE DLL and configuration files, which are required for any OGRE-based app to run. If you do not do this, you will need to copy a lot of the OGRE DLL and config files over to your output directory, as well as rework your config files and such to get it working properly. This is NOT recommended for your first shot at this.

Once that's done, we can start to use OGRE. Create a file called main.cpp, and see Setting Up An Application - Shoggoth.


Code Blocks

GCC & Code::Blocks

For Ogre 1.6.0 RC1 the Code::Blocks workspace is not correctly configured. Download the Ogre source from SVN instead. See this thread for additional information.

For Ogre 1.4 follow this link Code::Blocks + MinGW C++ Toolbox.

For Ogre 1.2.2 there is an alternative option of using Code::Blocks + MingW + STLPort

For Ogre 1.0.x with Code::Blocks 1.0RC2

Here are the steps to build Ogre with mandrav's excellent Code::Blocks IDE under Windows.

Performance Tip: It is suggested to disable Code::Blocks code completion plugin, before opening the Ogre workspace. This workspace contains ~40 projects which will be parsed. Since you 'll be building Ogre and not editing it, you won't be needing this parsing step.

Installation steps:

  1. Download the Ogre source distribution for Windows and unzip it. Everything will unpack in the ogre directory.
  2. Download codeblocks-dependencies-x.x.x.zip.
  3. Unzip codeblocks-dependencies-x.x.x.zip inside ogre (this creates the Dependencies directory)
  4. Launch Code::Blocks and open ogre/Ogre.workspace (wait until all projects have loaded)
  5. Hit "Build/Build Workspace"
  6. Sit back for a few minutes (17mins on a Intel P4 3.0G)
  7. Copy ogre/dependencies/bin/*.dll to ogre/samples/common/bin/release


Before being able to run the provided samples, you should comment out (using a hash # in front of it) the line Plugin=RenderSystem_Direct3D7 inside samples/common/bin/release/plugins.cfg.

You will need quake3 data files(.pk3 and .bsp) in order to run the BSP demo. If you have the files but got a ZipArchive::checkZzipError, just edit ogre\Samples\Common\bin\Release\quake3settings.cfg to point at your quake3 pak and bsp files.

You might have a problem building PlatformManager_Win32: The ogre/Ogre.workspace file has a 2 missing paths for the PlatformManager_Win32 build. To fix it, do the following:

  1. Right click on PlatformManager_Win32 in the workspace window on the left.
  2. Select "Build Options"
  3. Select the "Directories" tab and next the "Resource Compiler" tab.
  4. Add the following 2 directores ..\include and ..\misc, but clicking "Add" and the selecting those directories.
  5. Everything should build correctly now.


Enjoy!

MS Visual C++ Toolkit 2003 and Code::Blocks

Unfortunately the Visual C++ Toolkit does not come with necessary libraries for Multithreaded DLL compiling. This means you won't be able to compile Ogre with it, or at least not easily. The recommended solution for windows is to buy MSVC 7.1 or use [[#GCC & Code::Blocks|GCC]] with one of the IDEs available.

Discipline gave it a good shot at this thread in the forums. If you find a solution, please remove this and post it here. Also use the Codeblocks page for reference.

Update: You can get the multi-threaded dll runtime libraries by following the instructions at: http://manageddreams.com/osmpwiki/index.php?title=Notes_on_Microsoft_Visual_CPP_Toolkit_2003


Eclipse

If you want to compile Ogre on Windows without cygwin, pkgconfig, autotools, bootstrap, configure, etc. and use only gcc, then take a look : Building Under Eclipse And GCC

For question/suggestion use the forum thread : Eclipse + Gcc 3.4 (MinGW + Msys) + Ogre 1.0.3 (http://www.ogre3d.org/phpBB2/viewtopic.php?p=90097).

This is work in progress, feedback is appreciated. Help appreciated for a Linux + Mac version.
edit
(K)Ubuntu Linux Notes

  • Here (http://inetserver.europe.homeip.net/~heiko/?p=102) you can see what it takes to compile ogre on Ubuntu Linux.
  • If you run into linker problems with (K)Ubuntu and the aforementioned instructions, try issuing the command export CC=g++ before running ./configure


Setting Up The Anjuta IDE You might want to use an IDE to make your development in Ogre a tad easier. To do so, follow the instructions in this Ogre Forum Thread (http://www.ogre3d.org/phpBB2/viewtopic.php?t=5100), but to paraphrase:

  • Make a new Generic / Terminal
  • After following the prompts, change your Project->Project Options Configuration tab and Libraries sub-tab and add:

PKG_CHECK_MODULES(ogre, [OGRE >= 1.0.0])
AC_SUBST(ogre_CFLAGS)
AC_SUBST(ogre_LIBS)

  • Then go into Settings -> Compiler and linker options and add ${ogre_CFLAGS} to CFLAGS and ${ogre_LIBS} in Linker Flags
  • Finally, go to Build->Autogenerate and it should update your make and config files automatically.


Enjoy Ogre in Linux — bana


Cygwin

Use the following if you don't want to have to setup Code::Blocks, but would like to have just a pure Cygwin/MinGW environment. Cygwin is used for it's building system and since it can nicely cross-compile for MinGW, you will have a build that doesn't depend on Cygwin anymore.

Note: This information is ripped from this thread in the the Ogre forums.

  1. Fully install cygwin. You might need to add the correct path to /etc/profile.
  2. Get OGRE from CVS (there is a tutorial on how to do it in the CVS Access section). I put this on /usr/dev/ogre. This should also work with release version 1.0.0 or later - actually it worked with 1.0.0RC1 (I used the linux/OSX version. Didn't try the win32, but it must be not that different).
  3. Get the MingW/Cygwin OGRE dependencies from the OGRE website. Either extract it to the root (thus creating /mingw) or to another directory and create a symlink /mingw pointing to the correct location. If you want to build the OGRE dependencies yourself read Build OGRE dependencies using MSYS.
  4. Download and install libtool 1.5.12 (or newer). Version 1.5.10 (the one that came with cygwin) generates a few errors we want to avoid.
    1. Download the stable version from the libtool website.
    2. Configure and install it.
    3. Cygwin has a libtool wrapper that automatically selects 1.5.10 or 1.4.3 - we need to make it use our 1.5.12 (or newer) version instead. To do so, we first copy the libtool files from /usr/local/bin to /usr/autotool/1.5.x/bin (you'll have to create it), then edit /usr/bin/libtool to use that directory instead of the devel dir. It's just a quick, nasty hack - if someone knows of a better way to get the same result, please feel free to write your solution in right here. This shouldn't break anything though.
    4. (Optional): Go to a directory without configure.ac or configure.in files and do a 'libtool --version' to see if the first version number changed. If so, we can go to the next step.
  5. Follow the instructions on the beginning of this post, which I modified slightly and reproduce here. This is to be done in the ogre directory:
    1. export PATH="$PATH:/mingw/bin"
    2. export ACLOCAL_FLAGS="-I /mingw/share/aclocal"
    3. export PKG_CONFIG_PATH=/mingw/lib/pkgconfig
    4. ./bootstrap
    5. CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin" CXXFLAGS="-O2 -I/mingw/include" LDFLAGS="-L/mingw/lib -L/lib/w32api" ./configure --with-ft-prefix=/mingw --with-platform=Win32 --with-gl-support=Win32 --disable-static --build="i686-pc-mingw32" --enable-direct3d
    6. make
    7. make install
  6. Set up your development tools.
    1. Passing the arguments "-lOgreMain -Wl,--enable-runtime-pseudo-reloc" to the linker will work.
    2. As far as library directories go, you can link to cygwin/usr/local/lib and be happy about it.
    3. Include directories: cygwin/usr/local/include, cygwin/usr/local/include/OGRE and ogre/Samples/Common/include (if you are using the ExampleApplication class). Where I say cygwin/, I actually mean the cygwin path (such as c:/cygwin) and the same goes for ogre/ (c:/cygwin/usr/local/ogre/ogre, for example).
    4. This is not required, but I tend to copy all required DLLs to my build directory (the one where MingW puts my compiled binary in). By this, I keep my environment clean and you can just copy that directory to another computer and run it with its own dlls. This avoids mess.


There you go. You should be able to safely build any post-1.0.0 with this, unless there are some big changes that break the process.

Additional Notes :

  1. With the last releases of Cygwin, you don't have to compile a new libtool anymore.
  2. I had to tune the makefiles of several Plugins in order to compile: the ld option "-Wl,-z,defs" was refused. I replaced it with its other syntax "-Wl,--no-undefined" everytime I found it and it worked well.


GCC & Dev C++

Note: This is deprecated, and generally not recommended. DevCPP is old, the Ogre devpak is old, and you will have a much better time using Code::Blocks with MingW.


If you really, really want to do this, keep in mind that you are on your very own here. You are not likely to get any support on the OGRE Forum, other than people telling you to try other options.

You have been warned: Building From Source using DevCPP

Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()