To start doing something useful with my Mac, I started putting it to work in game development.
First thing on the agenda: Find a suitable Graphics Engine, that would compile on the Mac and the PC and ideally be able to run on iOS too, so I won’t have to learn a second Graphics Engine, when developing for iOS.
After initially looking through some sample code and the specs, Irrlicht got 2 Points over Ogre, because I liked the API a bit better and it could handle almost any resource format. Meaning, that I could throw Blender files, Images and Textures right at it, without converting them into an Engine-specific format.
Ogre on the other hand has a much more active community, better Sample and Tutorial features on it’s wiki (BIG Plus). What really sold it to me though, was an official support for iOS, that doesn’t exist on Irrlicht.
So Ogre it is then.
I do not like Xcode, which is the standard development enviroment on the Mac, simply because it does to much magic behind the scenes and has a way too obscure layout. So I am stuck with Eclipse, which is fine.
Getting Ogre to behave the way I want it too, was a bit of a hassle though.
I wanted Ogre to be contained in it’s own framework package, because I really like the idea behind the OsX pluggable frameworks.
Although Ogre does provide a framework package from the SDK, There are several libraries and all the Ogre-Plugins, outside the framework. These Ogre-Components (like libOgrePaging.dylib for instance) are essential to the Engine, so I don’t get, why they need to be outside the Ogre framework package.
Anyway, after copying those libs to the framework and including the framework in my project, I realized, that, while the OsX Compiler does understand to load things from frameworks (using a -fNameOfFramework) command line parameter, for some reason, the linker does not. Which lead me to the need of copying the main Ogre library, which is called Ogre without extensions inside the framework to a new file called libOgre.dylib and refer to that as well as to the framework.
Now to the fun part.
After successfully compiling and linking my example project, I tried to run it and got an Exception, reading that the OgrePaging library could not be found at @executable_path/../Components.
Turns out, that the Ogre library itself is dynamically linked to it’s component libraries at a very certain path. If that library is not in a directory called ‘Components’, that is reachable at ../Components from the executable running, it won’t work.
Since those libs are Ogre’s components and certainly not mine, that is unacceptable.
After a cry for help at the Ogre forums (which I can certainly recommend) the answer was: Compile the SDK from source and change the linkage (Installation Path) parameter of those libs to something like @executable_path/../Frameworks/Ogre.framkework/Components. That way, the library will be searched for inside a framework package, called Ogre.framework and delivered with the final application.
That is something I can live with, although I still don’t understand the need, to separate those libs in the first place, since they are obviously essential to the Ogre engine and could have easily been integrated into the main Ogre lib.
There is however some afterwork, you have to perform, after compiling with those new settings, in order to have the Ogre framework you wanted:
- Go to the Ogre build directory
- Create a folder called Components in lib/Release/Ogre.framework/Versions/1.7.2
- Create a folder called Plugins in the same place
- copy the library called Ogre from lib/Release/Ogre.framework/Versions/1.7.2/Ogre to lib/Release/Ogre.framework/Versions/1.7.2/libOgre.dylib, to satisfy your linker, which cannot handle frameworks correctly.
- create a link for Components in the framework main directory, using the command line (from the Framework root dir):ln -s Versions/Current/Components Components.
- Do the same for Plugins: ln -s Versions/Current/Plugins Plugins
- Copy the following files from the lib/Release directory to your newly created Components directory:
- Copy the following files from the lib/Release directory to your newly created Plugins directory:
One last thing needs to be done here, because Ogre has some dependencies to boost in it’s headers, so it needs the boost headers too.
That means, I needed to copy the dependencies headers to the Ogre framework’s Headers folder. The dependencies headers can be found in the Ogre-Dependencies, you had to download from Ogre in order to compile it.
I finally tamed that monster and I can now develop with Ogre on the Mac, by simply including the framework in my app package and nothing else is needed to run Ogre.
I still don’t get, why they made those Ogre-Components external Components which you would have to include as your application’s components in the application bundle of whatever you are developing, or why they bothered to externalize their functionality at all, since it seems to be absolutely vital to Ogre and therefore could have been included in the final Ogre library.