构建用于MacOSX的,但对连​​接适用于iOS模拟器文件建立的dylib [英] Building for MacOSX, but linking against dylib built for iOS Simulator file

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

问题描述

标准CMakeTestCCompiler.cmake尝试编译一个简单的测试程序中运行CMake的构建时,我刚刚升级到X code 5测试版在2013年4月15日命令行工具和命中以下警告>

  cmake的-version
cmake的版本2.8.11.2LD:建设MacOSX的,但对连​​接适用于iOS模拟器文件建立的dylib '/Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib'对于i386硬件架构脂-info /Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib
非FAT文件:libSystem.dylib是架构:I386

编译步骤是:

<$p$p><$c$c>/Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386的-isysroot /Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -o /Users/temp/testCCompiler.c.o -c /Users/temp/testCCompiler.c脂-info /Users/temp/testCCompiler.c.o
非FAT文件:testCCompiler.c.o是架构:I386

链接步骤是:

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

在这里link.txt包括:

<$p$p><$c$c>/Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386的-isysroot /Applications/X$c$c.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk轮候册,-headerpad_max_install_names /Users/temp/testCCompiler.c.o -o testCCompiler

似乎testCCompiler.c.o和libSystem.dylib都是I386,I386在link.txt规定,和i386是模拟器,所以我不知道为什么它认为它正在为MacOSX的正确的架构。也许一个命令行选项是错误的。(

感谢您的帮助!


解决方案

但问题是,X code 5取代GCC铿锵并以 - 三选项,指定OSX为目标补充道。如果传递-miphoneos版本分钟= 7.0在它的工作原理都GCC命令行。你可以看到铛命令行,如果你通过--verbose海湾合作委员会。这还需要添加到PATH为X code 5,这样的CMake可以找到所需的工具:出口PATH=/Applications/X$c$c5-DP6.app/Contents/Developer/Toolchains/X$c$cDefault.xct‌​oolchain/usr/bin:/Applications/X$c$c5-DP6.app/Contents/Developer/usr/bin:$PATH这一切都不是正式的..但我的工作至今。

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

The compile step is:

/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

The link step is:

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

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

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 :(.

thanks for any help!

解决方案

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天全站免登陆