Building a static lib for the iphone is kind of tricky. I couldn't find much documentation on the process, so here is the script I used to compile PCRE for the iphone. I'm using the 2.2 SDK in these examples... if you are using something different don't forget to change the path.
#!/bin/bash # This script will compile a PCRE static lib for the device and simulator cd pcre # Compile a version for the device... CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp \ AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar \ ./configure --disable-shared --host=arm-apple-darwin --disable-cpp \ CFLAGS="-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk" make mv .libs/libpcre.a .libs/libpcre_device.a # Compile a version for the simulator... CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \ CPP=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cpp \ AR=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar \ ./configure --disable-shared --disable-cpp \ CFLAGS="-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk" mv .libs/libpcre.a .libs/libpcre_simulator.a # Combine the two libs into one lib lipo -create .libs/libpcre_simulator.a .libs/libpcre_device.a -output ./libs/libpcre.a cp ./libs/libpcre.a YOU_PROJECT_DIR cp pcre.h YOU_PROJECT_DIR
Then all you have to do is add libpcre.a and pcre.h to your project and you'll be set for both simulator and device builds.
Recent Posts