Cross Compiling OGRE on Linux         How to compile Ogre apps for MS Windows from within Linux

Prerequisites

This tutorial assumes you have some basic Linux skills such as compiling applications from source and have some basic familiarity with your Linux distribution.

Introduction

You'll need the following things installed before continuing:


Note: This is a howto for Code::Blocks IDE, if you're using another IDE, refer to it's manual on setting up a new compiler.

Installing MinGW cross compiler in Ubuntu 6.06

I'm using Ubuntu 6.06 so it was preety easy to install the MinGW cross compiler, as explained on Code::Blocks wiki

Installing MinGW cross compiler in other distributions

I haven't tried installing MinGW cross compiler on any other distribution, so I leave this paragraph to other enthusiasts :-)

Gentoo

use crossdev.

Setting up the build environment

You'll need to download Ogre Code::Blocks for MS Windows SDK and extract it.
Since this file is an *.exe, use wine:

cd DownloadLocation
 wine OgreSDKSetup1.2.2_CBMingW_STLP.exe

Extract it to your prefered location ( In further text refered to as: (#OGRE_CB_SDK_DIR) )

Next you'll need to download Code::Blocks for MS Windows, again, installing it with Wine (further text: (#CB_DIR) )

Setting up Code::Blocks to compile Ogre apps for MS Windows

Since MingGW cross compiler is exactly the same as MinGW windows compiler, follow the Ogre Code::Blocks for MS Windows tutorial

Fixing STLPort compiler errors

I don't know why, but when I compile Ogre on MinGW-cross-compiler, after setting (#OGRE_CB_SDK_DIR)/stlport/stlport as a first include directory, headers in that folder report they cant find includes in "../3.44/*".

So I solved it the simplest way possibile:
copy folder (#CB_DIR)/include/c++/3.4.4 to (#OGRE_CB_SDK_DIR)/stlport

if anyone has a smarter solution, please let me know.

Final setup

And that's it! All that is left (but not necesarry) is to setup Code::Blocks target to output the executable to *.exe

Running exe applications

Now that you've successfully compiled your first Ogre app for MS Windows, it would be a good idea to see if it works. Ofcourse, the best way to test it is by running it on MS Windows, but it's easier if you test it on your machine first before handing it to others. so:

cd (#EXE_DIR)
 wine exe_name.exe


you should now see something like that screenshot above.

Note: Whilst Wine is a great piece of software, it still isn't perfect, so use Wine to see if your Ogre apps will start, but don't expect them to perform perfecly. eg. On my computer, when running my program using Wine, particles don't show properly, whilst the same exe runs perfectly on MS Windows.

Ogre 1.2.4 and the MinGW toolkit

Ogre3D development team has switched from MinGM + STLPort to MinGM with a modified libstdc++ which renders the default MinGW distribution useless.

So, you have two options:

  • Use Ogre's custom MinGW toolkit compiled for MS Windows. You'll have to use wine to run it. It works however it's very slow.
  • Compile a custom version of MinGW on linux. Since this is a very dificult task, especialy for linux newbies, I've compiled one myself (x86), DOWNLOAD


TODO: I've uploaded this file temporarily to my server, someone please move it to a more permanent location.

Troubleshooting

if you have any problems, send me an e-mail or PM.