构建MacOSX,但与为iOS模拟器文件构建的dylib连接

前端之家收集整理的这篇文章主要介绍了构建MacOSX,但与为iOS模拟器文件构建的dylib连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚刚使用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构建的.也许命令行选项是错误的:(.

感谢任何帮助!

解决方法

问题是Xcode 5用clang替换gcc,并添加一个指定OSX作为目标的“-triple”选项.如果您在两个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这些都不是官方的..但对我来说至今仍然有效.
原文链接:https://www.f2er.com/iOS/329284.html

猜你在找的iOS相关文章