-
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/arAnother example for armv7s using llvm-gcc 4.2 and targeting iPhone OS 5.1 with SDK 6.0 using Xcode 4.5
./configure --host=arm-apple-darwin --disable-shared CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 CFLAGS="-arch armv7 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -Wunused-value -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=5.1 " CPP=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/llvm-cpp-4.2 AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
make clean
make
cp lib/.libs/libidn.a libidn-armv7.aIf you want to compile for armv7s just replace armv7 with armv7s and copy the lib as explained above
For iPhone Simulator 6.0 or 5.1:
./configure --host=i686-apple-darwin --disable-shared CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 CFLAGS="-arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -Wunused-value -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=5.1 " CPP=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/llvm-gcc-4.2/bin/llvm-cpp-4.2 AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar
make clean
make
cp lib/.libs/libidn.a libidn-i386.aAfter having the three libs you should put them together in a fat binary as explained below:
lipo -create libidn-armv7s.a libidn-armv7.a libidn-i386.a -output libidn.aYou 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