./configure参数为iOS构建C库

时间:2014-06-25 16:25:28

标签: ios c xcode

我正在编写运行xml-rpc服务器的iOS应用程序。我在这里使用了C ++ for xml-rpc:http://xmlrpc-c.sourceforge.net/。该库使用./configure根据主机体系结构生成makefile,使用make, make install生成/安装库。

我需要在iOS应用程序中使用此库。我知道XCode使用了一个完全不同的构建系统,而且我是iOS开发的新手,所以我不太确定如何将库与我的应用程序联系起来。我需要用什么选项来传递./configure来编译iOS体系结构的库(我知道有三个目标,armv7,armv7s和i386)?

提前致谢。

1 个答案:

答案 0 :(得分:1)

以下是模拟器和设备平台的配置脚本选项。

  1. 模拟器(i386):

    $ ./configure --host=i386-apple-darwin --prefix <path_to_binaries> CFLAGS="-arch i386 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/ -miphoneos-version-min=4.0 --disable-cplusplus $ make $ make install

  2. iOS设备(arm):这有点棘手,而且有一个未解决的issue,但这里有一般步骤:

    $ ./configure --host=arm-apple-darwin --prefix <path_to_binaries> CFLAGS="-arch armv7s -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=4.0" --disable-curl-client --disable-cplusplus LDFLAGS='-arch armv7s -miphoneos-version-min=4.0 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk’
    $ make

  3. 特定于此库的注释:我们需要针对x86构建gen​​nmtab,因为它定义符号表并在编译程序的机器上运行 - 运行以下命令(从基本xmlrpc-xx.xxx目录开始) )

    $ cd lib/expat/gennmtab/
    $ rm gennmtab gennmtab.o 
    $ gcc -c gennmtab.c -o gennmtab.o -DNDEBUG -Wall -W -Wno-uninitialized -Wundef -Wimplicit -Winline -Wno-unknown-pragmas -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -fno-common -g -O3 -D_THREAD -I/Users/sradhakrishnan/dev/xmlrpc-c-1.25.28 -Isrcdir/lib/util/include   -I/Users/sradhakrishnan/dev/xmlrpc-c-1.25.28 -Isrcdir/lib/util/include
    

    现在gennmtab是针对x86构建的,继续执行以前的make,运行以下命令:

    $ cd ../../../ (you are back in the base xmlrpc-xx.xxx directory)
    $ make
    $ make install