We’re working on very interesting stuff for new products behind the scenes. It’s a special challenge to write cross platform code. For that reason we are creating a very solid code base that we can reuse in all future products. We decided to use C++ and wanted to support Mac OS X, Windows, iPhone OS and potentually Linux. Maybe I’ll write more about our concepts and decisions about that in a future post, but for now I’ll concentrate on Boost.
Boost is a collection of free cross platform and high-quality C++ libraries. Most of the classes can be used “header only”, so you include the appropriate header file in your code and it “just works”. Maybe the most famous class of Boost is the Smart Pointer class
shared_ptr. In our case we also needed the compiled libraries of Boost. Therefore we had to compile it amongst others for the iPhone. There are a few difficulties when building it for the iPhone and I had to google a lot until I found out all the details. Now I want to share my solution how I managed to build the Boost libraries for the iPhone – and here it is. I tried it with Boost version 1.42.0:
- You need a Mac with Mac OS X and installed iPhone SDK, of course.
- Download the Boost sources and extract them somewhere on your hard disc.
- In the directory with the Boost sources, open the file
tools/build/v2/user-config.jamand fill it with the following content:
using darwin : 4.2.1~iphone
: <architecture>arm <target-os>iphone <macosx-version>iphone-3.0
using darwin : 4.2.1~iphonesim
: <architecture>x86 <target-os>iphone <macosx-version>iphonesim-3.0
You have to adjust the paths if you have installed the iPhone SDK at a different location.
- Now open the file
tools/build/v2/tools/darwin.jamand add the missing line
- To build the Boost libraries for the iPhone Device, do the following:
bjam --prefix=/path/for/BoostiPhoneDeviceLibs --layout=versioned toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-3.0 define=_LITTLE_ENDIAN link=static install
/path/for/BoostiPhoneDeviceLibswith the path were you want to have the final Boost libraries and headers located.
- To build the Boost libraries for the Simulator, do the following:
bjam --prefix=/path/for/BoostiPhoneSimulatorLibs --layout=versioned toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-3.0 link=static install
/path/for/BoostiPhoneSimulatorLibswith the path were you want to have the final Boost libraries and headers located.
Unfortunately there are a few errors and warnings when building Boost for the iPhone this way. But because we currently do not use the affected classes yet, we did not spend much time into that.