IMPORTANT: These instructions are meant to be used with old releases of Ogre. For Ogre 1.10+, rather use BuildingOgre.md.
GCC Logo

This is command by command guide to build Ogre with MinGW under Windows. It is tested on Win7 and Ogre 1.9. 09/2014

Introduction

This tutorial is based on Building Ogre with boost 1.50 upwards and MinGW. I decided to write this after I have spent several days making Ogre compile on windows. There are some small things you can overlook, or forgot to do. On linux you basicaly run one sudo-apt-get-install command, one hg-clone, cd, mkdir build, make install -j8 and you are done. In windows this is not that simple. So here is mine command by command guide.

You almost do not have to think and you should end up with ogre ready to work. You just insert command after command in your command line. :-)

Download them all

You need to download all this and place/install it into the right directories (boost, MinGW). In case of ogre and ogre-dependencies you can run command in whatever place you like, the path to download is present in commands itselfs.

Build Boost

set PATH=%PATH%;C:\MinGW\bin;C:\MinGW\msys\1.0\bin
mkdir c:\boost\build
cd c:\boost\tools\build\v2
bootstrap.bat gcc
b2 install --prefix=C:\boost\build
set PATH=%PATH%;C:\boost\build\bin
cd c:\boost
b2 --build-dir=C:\boost\build toolset=gcc --build-type=complete stage


get a cofee, lunch or go to sleep, this will take several hours

move stage\lib ./
set PATH=%PATH%;C:\boost
set BOOST_ROOT=C:\boost
set Boost_DIR=C:\boost
setx BOOST_ROOT C:\boost
setx Boost_DIR C:\boost

Build Ogre dependencies

set PATH=%PATH%;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\boost;C:\Program Files (x86)\CMake 2.8\bin
cd c:\ogre-dep
mkdir build
cd build
cmake -G "MSYS Makefiles" ..
make install


This should take few minutes

cmake .. -DCMAKE_BUILD_TYPE=Debug
make clean
make install
#again... max few minutes
set OGRE_DEPENDENCIES_DIR=C:\ogre-dep\build\ogredeps
setx OGRE_DEPENDENCIES_DIR C:\ogre-dep\build\ogredeps

Build Ogre

These three build can run in separated command lines - you can save some time by this, provided you have more cores. Building Ogre will take few hours.

#Regular
set PATH=%PATH%;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\boost;C:\Program Files (x86)\CMake 2.8\bin
cd c:\ogre
hg update v1-9
mkdir build
cd build
cmake -G "MSYS Makefiles" .. -DOGRE_BUILD_RENDERSYSTEM_D3D11=FALSE
make install

#Debug
cd c:\ogre
mkdir buildd
cd buildd
cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:/ogre/build/sdk  -DOGRE_BUILD_RENDERSYSTEM_D3D11=FALSE
make install

#Small size librearies
cd c:\ogre
mkdir buildmin
cd buildmin
cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=C:/ogre/build/sdk  -DOGRE_BUILD_RENDERSYSTEM_D3D11=FALSE
make install


And finaly

set OGRE_HOME=C:\ogre\build\sdk
setx OGRE_HOME C:\ogre\build\sdk

Add things to PATH

Let us fall back to gui...
right click on "The computer"
Pick properties
Go to system variables
search for PATH
add this:

;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\boost;C:\Program Files (x86)\CMake 2.8\bin

to the end of PATH

Let us test

I have prepared small clean project which compiles fine under Linux and Windows

cd path/to/dev/directory
git clone https://github.com/kracejic/ogreclean.git
cd ogreclean


With these steps you will build and run this projects. If you have problems with off_t and off64_t, please see troubleshooting section at the end.

cd d:\some_path_to_your_project
mkdir build
cd build
cmake .. -G "MSYS Makefiles" -DOGRE_FRAMEWORK_INCLUDES=c:/ogre/build/sdk/include -DOGRE_FRAMEWORK_PATH=c:/ogre/build/sdk
make install
cd dist/bin
NameOfYourApp.exe

#If you want to have min size libraries use this cmake instead:
cmake .. -G "MSYS Makefiles" -DOGRE_FRAMEWORK_INCLUDES=c:/ogre/build/sdk/include -DOGRE_FRAMEWORK_PATH=c:/ogre/build/sdk -DCMAKE_BUILD_TYPE=MinSizeRel


Troubleshooting

Problems with off_t and off64_t


run editor on this file C:\MinGW\include\sys\types.h
You need to move change few line to look like this...
I know this is ugly, i did not have time to look for better solution, if you have one, please edit this page. :-)

#ifndef	_OFF_T_
#define	_OFF_T_
typedef long _off_t;
typedef _off_t	off_t;
#ifndef __STRICT_ANSI__
#endif /* __STRICT_ANSI__ */
#endif	/* Not _OFF_T_ */

#ifndef _OFF64_T_
#define _OFF64_T_
typedef __int64 _off64_t;
typedef __int64 off64_t;
#ifndef __STRICT_ANSI__
#endif /* __STRICT_ANSI__ */
#endif /* ndef _OFF64_T */