Compiling a Static Library for iPhone Device..

已查看 102 次
跳至第一个未读帖子

youdon...@gmail.com

未读,
2009年2月6日 12:44:062009/2/6
收件人 Protocol Buffers
I'm attempting to configure and compile a static library for GPBs for
the iPhone.

It seems that every library I create ends up working great in the
Simulator (Intel platform), but gets linker errors when I compile for
the Device (ARM platform). The errors all come in the form:

"google::protobuf::UnknownFieldSet::UnknownFieldSet()", referenced
from:" followed by the .o files the function is referenced in.

I'm using the following configure options:

./configure --host=arm-apple-darwin --program-prefix=iphone --disable-
shared --disable-crypto-auth --without-gnutls --without-ssl --without-
zlib --without-libssh2 --disable-ipv6 --disable-manual --disable-
telnet --disable-tftp --disable-ldap --disable-file --disable-ftp CC=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-
darwin9-g++-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 -I/Library/iPhone/include -isysroot /Developer/
Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk" CPP=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar AS=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/
Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib

When I run 'file libprotobuf.a', I get the message 'Current ar
archive'. Does this mean it's an ARM library?

Any help would be greatly appreciated.

Thanks,
Mike


John

未读,
2009年3月6日 18:25:272009/3/6
收件人 Protocol Buffers
Almost :-)

I was looking to do the same thing - thanks for the helping hand with
the script.

I tried yours - failed, the command 'lipo -info <libname>' said I had
created an i386 library. Ahhhhh I thought to meself...

So here's my build script, derived from yours:

----------------- beginning of bash script file ---------------
#!/bin/bash

MY_FLAGS="-arch armv6 -pipe -Wno-trigraphs -fpascal-strings -fasm-
blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -
fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -I/
Library/iPhone/include -isysroot /Developer/Platforms/
iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk"

export CFLAGS="$MY_FLAGS"
export CXXFLAGS="$MY_FLAGS"

export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-
apple-darwin9-g++-4.0.1
export GXX=$CC

export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
cpp
export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
export AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as
export LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/
bin/libtool
export STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
strip
export RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
ranlib

CONFIGURE="./configure --host=arm-apple-darwin --prefix=/usr/local/
iphone-protobuf203 --program-prefix=iphone --disable-shared --disable-
crypto-auth --without-gnutls --without-ssl --without-zlib --without-
libssh2 --disable-ipv6 --disable-manual --disable-telnet --disable-
tftp --disable-ldap --disable-file --disable-ftp"

------------------- end of bash script file -------------------


right. save that as a script file somewhere, then 'source' it into
your current shell.

then you do something like this:
$ source <location of that script>
$ $CONFIGURE
$ make install-exec

and your done. I reckon your problem was that you'd CONFIGURED
properly, but since you hadn't exported the env vars for C and CXX
settings, the compile took place as normal.
回复全部
回复作者
转发
0 个新帖子