ios - ./configure 参数为 iOS 构建 C 库

标签 ios c xcode

我正在编写一个运行 xml-rpc 服务器的 iOS 应用程序。我正在使用此处提供的用于 xml-rpc 的 C 库:http://xmlrpc-c.sourceforge.net/ .该库使用 ./configure 根据主机架构生成 makefile,并使用 make, make install 构建/安装库。

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

提前致谢。

最佳答案

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

  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):这有点棘手,还有一个 Unresolved 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

特定于此库的说明:我们需要针对 x86 构建 gennmtab,因为它定义了符号表并且将在编译程序的机器上运行 - 运行以下命令(从基本 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

现在已经针对 x86 构建了 gennmtab,通过运行以下命令继续之前的 make:

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

关于ios - ./configure 参数为 iOS 构建 C 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24413974/

相关文章:

ios - SwiftyJSON 对象返回字符串

objective-c - 你必须在 UIButton 上调用 removeTarget 吗?

将一个 char 数组复制到另一个 char 数组数组

iOS 应用上传到应用商店无效的配置文件

ios - 在本地化的 xib 文件中无法识别非本地化图像

ios - 在 UIAlertController 中添加复选框

ios - 分配周末 FSCalendar

c - 词法分析器的输出应该是什么?

python - 在C或其他编译器语言之前学习Python是一个好主意吗?

mysql - Vapor MySQL 时间戳默认值