小编use*_*420的帖子

为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
Run Code Online (Sandbox Code Playgroud)

编译步骤是:

/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
Run Code Online (Sandbox Code Playgroud)

链接步骤是:

/usr/local/bin/cmake -E cmake_link_script /Users/temp/link.txt --verbose=1
Run Code Online (Sandbox Code Playgroud)

其中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
Run Code Online (Sandbox Code Playgroud)

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

谢谢你的帮助!

c cmake clang ld

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

clang ×1

cmake ×1

ld ×1