I have successfully cross-compiled the Apache Portable Runtime (APR) for the iPhone, using a set of configure scripts that invoke the GNU Autotools "./configure" with the necessary cross-compilation options.
I am now attempting to cross-compile GNUTLS which depends on libtasn1 and on libgcrypt, which in turn, depends on libgpg-error. This is where I am running into trouble and could use your help...
I am currently trying to cross-compile libgpg-error. The configure scripts that I used before are working beautifully; the "./configure" process completes cleanly. The problems occur when I run "make". When I run make, everything seems to compile, but then I get the following nasty linker error at the end:
/bin/sh ../libtool --tag=CC --mode=link /Users/michaelsafyan/Downloads/libgpg-error-1.7/compile /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk' -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.0/include -isystem /usr/local/iphone-3.0/include -arch armv6 --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk' -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -L/opt/iphone-3.0/lib -L/usr/local/iphone-3.0/lib -o gpg-error gpg_error-strsource-sym.o gpg_error-strerror-sym.o gpg_error-gpg-error.o ./libgpg-error.la /Users/michaelsafyan/Downloads/libgpg-error-1.7/compile /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.0/include -isystem /usr/local/iphone-3.0/include -arch armv6 --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -o gpg-error gpg_error-strsource-sym.o gpg_error-strerror-sym.o gpg_error-gpg-error.o -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -L/opt/iphone-3.0/lib -L/usr/local/iphone-3.0/lib ./.libs/libgpg-error.a Undefined symbols: "_fwrite$UNIX2003", referenced from: _main in gpg_error-gpg-error.o "_strerror$UNIX2003", referenced from: _gpg_strerror in libgpg-error.a(libgpg_error_la-strerror.o) ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [gpg-error] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
Any ideas on how to get this to work? The versions of the software that I am compiling are:
- libgpg-error: 1.7
- libgcrypt: 1.4.4
- libtasn1: 2.2
- gnutls: 2.8.4
Please help. Thank you.
Update
As per initial feedback, each SDK has a copy of "libSystem.dylib" in "$SDKROOT/usr/lib". There is no copy of libSystem in "$DEVROOT/usr/lib", where:
- $DEVROOT = "/Developer/Platforms/iPhoneOS.platform/Developer"
- $SDKROOT = "$DEVROOT/SDKs/iPhoneOS$VER.sdk"
The "libSystem" libraries contain the ordinary, undecorated versions, of each symbol, but do not contain the "$UNIX2003" variants of the symbols. I suspect that GPG-ERROR is defining "_POSIX_C_SOURCE", "_UNIX", or another UNIX feature test macro, and that a rogue header that is appending "$UNIX2003" to the functions when these feature test macros are present is being included. Removing "$DEVROOT/usr/include" from the list of include directories has no effect with regard to removing this error message.
As a last resort, I see that "ld" accepts an "-alias_list" option that allows one to specify a file with entries like "_fwrite _fwrite$UNIX2003" to forcibly resolve these undefined symbols to their undecorated variants. If possible, I would like to avoid this option, since it seems hackish and potentially dangerous.