我刚刚使用2013年4月15日的命令行工具升级到Xcode 5 beta,并且在标准CMakeTestCCompiler.cmake尝试编译简单测试程序期间运行cmake构建时遇到以下警告:
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包含:
/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,i386是在link.txt中指定的,而i386是模拟器的正确架构,所以我不确定为什么它认为它是为MacOSX构建的。也许命令行选项是错误的:(。
感谢您的帮助!
答案 0 :(得分:23)
问题是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这些都不是官方的...但到目前为止对我有用。
答案 1 :(得分:1)
在您的client.app:
上运行此评论export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH