wiki:GameDevelopment/Ogre/BuildingOgreOnMinGw

Version 2 (modified by Vijay Varadan, 8 years ago) (diff)

Fixed outdated link to "Building boost on MinGW".

Building Ogre3D 1.81 on MinGW

Oct 31 2012

Ogre 3D

Assumptions: You're familiar with Windows & Unix utilities, shell scripting ( bash & cmd ), have knowledge of command line compilation and are generally fearless, like a lion.

I put all third party code in ~/external, build them to ~/build/output and install them to ~/build/install. I eschew system wide installs and prefer to use local installation where possible, but I don't fight it too much - take the case of python. I'd prefer a simple unzip of python, but that doesn't work for a bunch of stuff ( like mercurial, NumPy, pygame ) that looks for registry entries in Windows for successful installation. So, I just use the installer from the python.org site.

Building Ogre

Here's my development setup:

PlatformWindows 7 x64
Toolchainmingw gcc on msys which you can get here.
gcc version4.7.0 - get this with mingw
python version2.7.3 for x86 from python.org
mercurial version2.3.2 for x86, I use the python package. From the official site.
Ogre version1.8.1 from the bitbucket repo
Ogre dependenciesdefault branch from the bitbucket repo
Boost version1.51
DirectX SDK versionJune 2010
If you run into issues, see this Stack Overflow question

Step 1: Boost

This step is completely optional, as boost is not a required dependency. I'm planning on using multi-threading and a whole host of boost libraries. See the post Building boost on MinGW. Note: I build everything in boost, rather than just the bare minimum required for multi-threading.

Step 2: Ogre Dependencies

  1. Get a bitbucket account if you don't already have one. Add your ssh pub key to the account - there are instructions on the bitbucket site, if you don't already know how to do this. You can use https instead of ssh, but modify the URL passed to hg clone accordingly.
  2. Fetch the source code.
    export OGRE_SOURCE_DIR=~/external/ogre/v1-8
    mkdir -p $OGRE_SOURCE_DIR
    cd $OGRE_SOURCE_DIR
    hg clone ssh://hg@bitbucket.org/cabalistic/ogredeps
    export OGREDEPS_SOURCE_DIR=$OGRE_SOURCE_DIR/ogredeps
    
  3. Set up some environment vars and build the deps:
    export BUILD_OUTPUT_DIR=~/build/output
    export OGRE_OUTPUT_DIR=$BUILD_OUTPUT_DIR/ogre/v1-8
    export OGREDEPS_OUTPUT_DIR=$OGRE_OUTPUT_DIR/ogredeps
    export BUILD_INSTALL_DIR=~/build/install
    export OGREDEPS_INSTALL_DIR=$BUILD_INSTALL_DIR/ogredeps
    mkdir -p $OGREDEPS_OUTPUT_DIR
    cd $OGREDEPS_OUTPUT_DIR
    
  4. If you're using MinGW under MSYS:

cmake $OGREDEPS_SOURCE_DIR -G "MSYS Makefiles"

or if you're using MinGW without MSYS:

cmake $OGREDEPS_SOURCE_DIR -G "MinGW Makefiles"

make
mkdir $BUILD_INSTALL_DIR
make install
mv ogredeps $OGREDEPS_INSTALL_DIR

Step 3: Ogre SDK

This is rather similar to building the dependencies.

  1. Fetch the source code.
    export OGRE_SOURCE_DIR=~/external/ogre/v1-8
    mkdir -p $OGRE_SOURCE_DIR
    cd $OGRE_SOURCE_DIR
    hg clone ssh://hg@bitbucket.org/sinbad/ogre
    export OGRESDK_SOURCE_DIR=$OGRE_SOURCE_DIR/ogre
    
  2. We need to tell Ogre where boost is:
    export BOOST_ROOT=~/build/install/boost_1_51_0
    export BOOST_INCLUDEDIR=$BOOST_ROOT/include/boost-1_51
    export BOOST_LIBRARYDIR=$BOOST_ROOT/library
    
    On posix systems, you don't need to set BOOST_INCLUDEDIR or BOOST_LIBRARYDIR, but if you do set them, BOOST_INCLUDEDIR should be set as follows: export BOOST_INCLUDEDIR=$BOOST_ROOT/include
  3. And where the dependencies are: export OGRE_DEPENDENCIES_DIR=~/build/install/ogredeps
  4. Set up some environment vars for build and install locations:
    export BUILD_OUTPUT_DIR=~/build/output
    export OGRE_OUTPUT_DIR=$BUILD_OUTPUT_DIR/ogre/v1-8
    export OGRESDK_OUTPUT_DIR=$OGRE_OUTPUT_DIR/ogre
    export BUILD_INSTALL_DIR=~/build/install
    export OGRESDK_INSTALL_DIR=$BUILD_INSTALL_DIR/ogre
    mkdir -p $OGRESDK_OUTPUT_DIR
    cd $OGRESDK_OUTPUT_DIR
    
  5. If you're using MinGW under MSYS:

cmake $OGRESDK_SOURCE_DIR -G "MSYS Makefiles"

or if you're using MinGW without MSYS:

cmake $OGRESDK_SOURCE_DIR -G "MinGW Makefiles"

make
mkdir $BUILD_INSTALL_DIR
make install
mv sdk $OGRESDK_INSTALL_DIR

At this point, you should have your boost stuff in #!bash ~/build/install/boost_1_51_0 , ogre dependencies in #!bash ~/build/install/ogredeps and the ogre sdk in #!bash ~/build/install/ogre . To build applications, simply add the relevant include and library paths to the compiler and linker options. On posix systems, add the bin directories to LD_LIBRARY_PATH environment variable. On Windows and MinGW, add the bin directories to the PATH environment variable.