HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了构建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这些都不是官方的..但对我来说至今仍然有效.

大佬总结

以上是大佬教程为你收集整理的构建MacOSX,但与为iOS模拟器文件构建的dylib连接全部内容,希望文章能够帮你解决构建MacOSX,但与为iOS模拟器文件构建的dylib连接所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。