为 MacOSX 构建,但链接到为 iOS 模拟器文件构建的 dylib [英] Building for MacOSX, but linking against dylib built for iOS Simulator file

查看:21
本文介绍了为 MacOSX 构建,但链接到为 iOS 模拟器文件构建的 dylib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 2013 年 4 月 15 日的命令行工具升级到 Xcode 5 beta,并在标准 CMakeTestCCompiler.cmake 尝试编译一个简单的测试程序期间运行 cmake 构建时遇到以下警告:

I've just upgraded to Xcode 5 beta with the April 15 2013 commandline tools and hit the following warning when running a cmake build during the standard CMakeTestCCompiler.cmake attempt to compile a simple test program:

cmake -version
cmake version 2.8.11.2

ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib' for architecture i386

lipo -info /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib
Non-fat file: libSystem.dylib is architecture: i386

编译步骤是:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -o /Users/temp/testCCompiler.c.o -c /Users/temp/testCCompiler.c

lipo -info /Users/temp/testCCompiler.c.o 
Non-fat file: testCCompiler.c.o is architecture: i386

链接步骤是:

/usr/local/bin/cmake -E cmake_link_script /Users/temp/link.txt --verbose=1

其中 link.txt 包含:

where link.txt contains:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -Wl,-headerpad_max_install_names /Users/temp/testCCompiler.c.o -o testCCompiler

似乎 testCCompiler.c.o 和 libSystem.dylib 都是 i386,在 link.txt 中指定了 i386,而 i386 是模拟器的正确架构,所以我不确定为什么它认为它是为 MacOSX 构建的.也许命令行选项是错误的:(.

It seems that both testCCompiler.c.o and libSystem.dylib are i386, i386 is specified in link.txt, and i386 is the right architecture for the simulator so i'm not sure why it thinks it is building for MacOSX. Perhaps a commandline option is wrong :(.

感谢您的帮助!

推荐答案

问题是 Xcode 5 用 clang 替换了 gcc,并添加了一个-triple"选项,指定 OSX 作为目标.如果在两个 gcc 命令行上都传递-miphoneos-version-min=7.0",它就可以工作.如果将--verbose"传递给 gcc,您可以看到 clang 命令行.还需要添加到 Xcode 5 的 PATH 中,以便 cmake 可以找到必要的工具:export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct‌ oolchain/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH 这些都不是官方的..但到目前为止对我有用.

The problem was that Xcode 5 replaces gcc with clang and adds in a "-triple" option that specifies OSX as the target. If you pass "-miphoneos-version-min=7.0" on both gcc command lines it works. You can see the clang command line if you pass "--verbose" to gcc. It's also necessary to add to the PATH for Xcode 5 so that cmake can find the necessary tools: export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct‌​oolchain/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH None of this is official.. but works for me so far.

这篇关于为 MacOSX 构建,但链接到为 iOS 模拟器文件构建的 dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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