从命令行,Xcode 7-beta 2编译iOS 9的C库 [英] Compiling C Library for iOS 9 From Command Line, Xcode 7-beta 2

查看:124
本文介绍了从命令行,Xcode 7-beta 2编译iOS 9的C库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用最新的Xcode 7-beta clang为iOS 9编译C库(gmp).我试图产生位代码以使Xcode中的所有警告停止(并且我想以位代码产生这些库).但是,我什至无法编译该库. ./configure失败,并且在查看config.log之后,看来ld是问题所在,因为它失败了,原因是"ld:-lSystem找不到库".这是我过去用来编译gmp的命令:

I am having trouble compiling a C library (gmp) for iOS 9 using the latest Xcode 7-beta clang. I am trying to produce bitcode to get all the warnings in Xcode to stop (and I would like to produce these libraries in bitcode). However, I can't even compile the library in the first place. ./configure fails, and after looking at the config.log, it seems ld is the problem as it is failing with "ld: library not found for -lSystem". Here is the command I have used to compile gmp in the past :

./configure CC=clang CPP="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xct‌​oolchain/usr/bin/clang -E" CPPFLAGS="-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Deve‌​loper/SDKs/iPhoneOS.sdk/ -L /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Deve‌​loper/SDKs/iPhoneOS.sdk/usr/lib/ -miphoneos-version-min=7.0 -arch armv7 -target arm-apple-darwin

The

-L /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Deve‌​loper/SDKs/iPhoneOS.sdk/usr/lib/

我添加的

标志是为了查看这是否有助于ld查找所需的链接库,但是无论是否包含该选项,它都会失败并出现相同的错误.我没有在上述命令中包含编译成位码的选项,因为我什至无法使用我以前使用的相同命令来编译它.我注意到,当我将gmp .a文件添加到链接库中的二进制文件"下的xcode时,ld无法找到这些库.我必须将项目手动添加到项目设置中的ld搜索路径中,以便ld查找库.这在Xcode 6中不是必需的,所以它仅仅是在当前Beta版中出现故障,还是我可以做些什么?

flag I added is to see if that would help with ld finding the required libraries to link, but it fails with the same error whether I include that option or not. I have not include the option to compile into bitcode in the above command, as I I can't even get it to compile in the first place using the same command I used to use. I have noticed that when I add the gmp .a files to xcode under "link binary with libraries", that ld can't find the libraries. I must manually add the project to the ld search path in the project settings for ld to find the libraries. This wasn't necessary in Xcode 6, so is it just ld being buggy in the current beta, or is there anything I can do?

推荐答案

好的,这是可行的.将您的xcode开发设置为使用

Okay, here is what worked. Set your xcode development to use the new compilers using

sudo xcode-select -s /Applications/Xcode-beta.app

然后,我使用此配置:

./configure CC=clang CPP="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E" CPPFLAGS="-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ -fembed-bitcode -miphoneos-version-min=7.0 -arch armv7 -target arm-apple-darwin" --host=aarch64-apple-darwin --disable-assembly --enable-static --disable-shared --disable-thread-safe --enable-cxx

以上内容在编译mpfr和mpc时也有效.

The above works when compiling mpfr and mpc also.

这篇关于从命令行,Xcode 7-beta 2编译iOS 9的C库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆