wiki:SystemNotesiOS

This system notes describe a process to build Kea on MacOS X (aka the build system) for iOS (aka iPhoneOS, the host system). The goal is not build a real/working application but to explore cross compiling.

0. install necessary tools.

You need a recent version of Xcode (e.g., Xcode 6.1.1) on OS X (e.g., OS X 10.10.2) with the iPhoneOS SDK installed. Note as you'll need a version of the message compiler for the building system (i.e., OS X here) you have to install Xcode command line tools, a package system like brew, etc, as explained in wiki:SystemNotesMacOSX109.

1. setup build environment.

Most of the dependencies and Kea itself are based on GNU autotools. The required environment variables are:

PLATFORM=iphoneos
ARCH=<the ARM version, e.g., armv7>
ROOTDIR=<the directory where you want to install things>
PPATH=`xcrun --show-sdk-platform-path --sdk $PLATFORM`
SDK=$PPATH/Developer/SDKs/iPhoneOS`xcrun --show-sdk-version --sdk $PLATFORM`.sdk

export CC="xcrun -sdk $PLATFORM gcc -arch $ARCH"
export CXX="xcrun -sdk $PLATFORM g++ -arch $ARCH"

export AR="xcrun -sdk $PLATFORM ar"
export DSYMUTIL="xcrun -sdk $PLATFORM dsymutil"
export LIPO="xcrun -sdk $PLATFORM lipo"
export NM="xcrun -sdk $PLATFORM nm"
export NMEDIT="xcrun -sdk $PLATFORM nmedit"
export RANLIB="xcrun -sdk $PLATFORM ranlib"
export STRIP="xcrun -sdk $PLATFORM strip"
export OTOOL="xcrun -sdk $PLATFORM otool"

export CFLAGS="-O2 -isysroot $SDK"
export CXXFLAGS="-O2 -isysroot $SDK"

export BUILD_CC=gcc
export BUILD_CXX=g++

export PKG_CONFIG_PATH=$ROOTDIR/lib/pkgconfig

The list of SDKs is given by xcodebuild -showsdks, note the iOS simulator won't really help as its goal is only the user interface. Typically dependencies (lib4cplus, sqlite, etc) and Kea are built by:

./configure --prefix=$ROOTDIR --host=$ARCH-apple-darwin
make
make install

When you need to provide an explicit path usually $ROOTDIR is the right answer.

2. special cases.

Boost is a special but easy case: you have to copy the boost directory in $ROOTDIR/include and refers to it, e.g., by:

--with-boost-include=$ROOTDIR/include

Botan is a nightmare. First you must get the Makefile by:

python configure.py --cpu=$ARCH --cc=gcc --os=darwin --prefix=$ROOTDIR --with-tr1-implementation=none

and edit it replacing command definitions by xcrun calls. Note the MACH_OPT variable is not used everywhere so the CPU architecture must be in CXX.

OpenSSL is easier and there are some docs about it in the Web. This works:

PLATFORM=iphoneos
ARCH=<the ARM version, e.g., armv7>
ROOTDIR=<the directory where you want to install things>
PPATH=`xcrun --show-sdk-platform-path --sdk $PLATFORM`
SDK=$PPATH/Developer/SDKs/iPhoneOS`xcrun --show-sdk-version --sdk $PLATFORM`.sdk

export CC="xcrun -sdk $PLATFORM gcc -arch $ARCH"
export CROSS_TOP=$PPATH/Developer
export CROSS_SDK=iPhoneOS`xcrun --show-sdk-version --sdk $PLATFORM`.sdk

for environment variables and for the config itself:

--prefix=$ROOTDIR shared iphoneos-cross

Notes:

  • --prefix is a bit better than --openssldir
  • shared is not the default so you have to add it
  • sysroot stuff is handled by the cross entry

3. final build.

Kea is built using ./configure but:

  • the pkgconfig path is applied before (not instead) the system path so you must check you use the cross compiled version.
  • a message compiler must be built for the building system and copied to <kea>/src/lib/log/compiler/message (./configure raises a warning when it can't find it).
  • if you want a particular version of Boost you must give its path (kea uses only the Boost headers, not any Boost library, so it should work as soon as it can find them).

The result is not supposed to work on an iPhone or an iPad: this is a cross compiling test only.

Last modified 3 years ago Last modified on Mar 10, 2015, 12:00:51 AM