xcode 在 llvm-gcc-4.2 中使用 iOS 7 SDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18890368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using iOS 7 SDK with llvm-gcc-4.2
提问by podkova
I've installed xcode 5 and noticed that gcc compiler is deprecated. Assuming that I don't want to switch to Apple LLVM 5.0, here come my questions:
我已经安装了 xcode 5 并注意到 gcc 编译器已被弃用。假设我不想切换到 Apple LLVM 5.0,那么我的问题来了:
Is it possible to use iOS7 SDK and still compile in llvm-gcc-4.2?
是否可以使用 iOS7 SDK 并仍然在 llvm-gcc-4.2 中编译?
If yes, how to do this?
如果是,如何做到这一点?
If you don't know if that's possible, please don't post answers like "use clang, man", because they are not actually answeringthe questions I've posted.
如果您不知道这是否可行,请不要发布诸如“使用 clang,伙计”之类的答案,因为它们实际上并没有回答我发布的问题。
采纳答案by rakmoh
Apple has removed the support for llvm-gcc-4.2 in XCode 5. Even if you install and change your base sdk to 6.1 sdk, you won't be able to build using llvm-gcc-4.2. So your only option is to continue using XCode 4.x if you want to use llvm-gcc-4.2.
Apple 已在 XCode 5 中删除了对 llvm-gcc-4.2 的支持。即使您安装了基础 sdk 并将其更改为 6.1 sdk,您也无法使用 llvm-gcc-4.2 进行构建。因此,如果您想使用 llvm-gcc-4.2,您唯一的选择是继续使用 XCode 4.x。
回答by Ravindhiran
LLVM-GCC is not included in Xcode 5.
LLVM-GCC 不包含在 Xcode 5 中。
I got above line from https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_5_0.html
我从https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_5_0.html得到了上面的一行
So the question is what to use instead of llvm-gcc ?
所以问题是用什么代替 llvm-gcc ?
回答by Chris Devereux
Is it possible to use iOS7 SDK and still compile in llvm-gcc-4.2?
是否可以使用 iOS7 SDK 并仍然在 llvm-gcc-4.2 中编译?
If you want to compile your whole appusing llvm-gcc-4.2: Probably not. I haven't checked this myself, but the iOS 7 headers would only need to add a single dependency on a clang feature missing in llvm-gcc-4.2 and you're swimming in compile errors. You may be able to hack your way through them, but it would likely be easier (not to mention more future-proof) to suck it up and upgrade to clang.
如果您想使用 llvm-gcc-4.2编译整个应用程序:可能不是。我自己还没有检查过这个,但是 iOS 7 头文件只需要添加对 llvm-gcc-4.2 中缺少的 clang 功能的单一依赖项,并且您在编译错误中游泳。您也许可以破解它们,但吸收它并升级到 clang 可能会更容易(更不用说更具前瞻性了)。
If you only need to compile some of your appusing llvm-gcc-4.2: Sure, as long as you don't need to import any iOS 7 headers in the parts that you build with llvm-gcc-4.2.
如果您只需要使用 llvm-gcc-4.2编译您的某些应用程序:当然,只要您不需要在使用 llvm-gcc-4.2 构建的部分中导入任何 iOS 7 头文件。
You could try moving the problematic bits off to a static library, compiling that with gcc, then linking in to the final app, built with clang. You won't be able to target 64-bit, as llvm-gcc-4.2 doesn't can't generate armv8 code, but it should work otherwise.
您可以尝试将有问题的部分移到静态库中,使用 gcc 对其进行编译,然后链接到使用 clang 构建的最终应用程序。您将无法定位 64 位,因为 llvm-gcc-4.2 不能生成 armv8 代码,但它应该可以正常工作。
One caveat: If your static lib uses C++, there may be some problems due to ABI and std library differences. But those are solvable problems, at least.
一个警告:如果您的静态库使用 C++,由于 ABI 和 std 库的差异,可能会出现一些问题。但至少,这些都是可以解决的问题。
回答by DarthMike
You could use homebrewto install the gcc version you need. Most probably all your Makefiles will need to be corrected (sigh)
您可以使用自制软件来安装您需要的 gcc 版本。很可能你所有的 Makefile 都需要更正(叹气)
I did:
我做了:
brew search gcc
And the results:
结果:
homebrew/versions/gcc43
homebrew/versions/gcc45
homebrew/versions/gcc47
homebrew/versions/gcc49
homebrew/versions/gcc44
homebrew/versions/gcc45
homebrew/versions/gcc48
homebrew/versions/llvm-gcc28
homebrew/dupes/apple-gcc42