-
Notifications
You must be signed in to change notification settings - Fork 2.1k
CompilingLibidn
How to compile libidn for the iPhone.
A precompiled fat binary, libidn.a, with support for the iPad, iPhone, iPod touch and simulator is included in xmppframework.
The libidn source code is included in the XMPP framework libidn directory. The code was obtained from the libidn project page.
Here is how it was compiled for the iPhone.
Expand the libidn source code from its tar or tgz format. Open the terminal, and cd to the expanded directory. It only takes 3 commands to compile the source. (Notice that the first command is one big long command.)
./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --disable-shared CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS="-arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
make
sudo make installYou'll find the libraries in /usr/local/iphone/lib
Reference: http://discussions.apple.com/thread.jspa?threadID=1546383
Note: The above command may be a bit dated. Everytime I update the command to reflect the latest compiler / iOS SDK, Apple goes and updates the SDK or compiler tools. But this should get you on the right track.
The following can be used to compile the library for armv7 using GCC 4.2 and targeting iPhone OS 3.1.2:
./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --disable-shared CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 CFLAGS="-arch armv7 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -Wunused-value -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=3.1.2 " CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arYou may wish to compile the library for multiple architectures and create a fat binary. This is helpful because then you can link to the same file whether you're compiling for the desktop, simulator or iphone device.
Compile all the different versions you want, put them in the same folder, and then use a command like this:
lipo -create libidn_desktop.a libidn_armv6.a libidn_armv7.a -output libidn.a