1

所以我在使用 scan-build 构建 xcode 项目时遇到链接器错误

对于我正常的 xcodebuild 命令,我使用以下命令

xcodebuild -target LibCoreMobileGHUnit -configuration Debug -sdk iphonesimulator5.0 clean build

它对链接器阶段使用以下选项

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
-demangle
-dynamic
-arch i386
-all_load
-ios_simulator_version_min 5.0.0
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
-ObjC
-o /Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator/LibCoreMobileGHUnit.app/LibCoreMobileGHUnit
-lcrt1.o
-L/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator
-filelist /Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/LibCoreMobile.build/Debug-iphonesimulator/LibCoreMobileGHUnit.build/Objects-normal/i386/LibCoreMobileGHUnit.LinkFileList
-objc_abi_version 2
-no_implicit_dylibs
-lz
-framework QuartzCore
-framework UIKit
-framework Foundation
-framework CoreGraphics
-framework GHUnitIOS
-force_load /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a
-framework Foundation
-lobjc
-lc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.profile_ios.a
-lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.ios.a
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator
-F/Applications/Xcode.app/Contents/Developer/Library/Frameworks
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/LibCoreMobileGHUnit
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/ExternalFrameworks

这是成功的

但是当我运行以下

scan-build -k -v -v -o ../clangScanBuildReports xcodebuild -target LibCoreMobileGHUnit -configuration Debug -sdk iphonesimulator5.0 clean build

它与以下选项链接:

"/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld"
-dynamic
-arch i386
-all_load
-ios_simulator_version_min 5.0.0
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
-ObjC
-o /Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator/LibCoreMobileGHUnit.app/LibCoreMobileGHUnit
-lcrt1.o
-L/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator
-filelist /Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/LibCoreMobile.build/Debug-iphonesimulator/LibCoreMobileGHUnit.build/Objects-normal/i386/LibCoreMobileGHUnit.LinkFileList
-objc_abi_version 2
-no_implicit_dylibs
-lz
-framework QuartzCore
-framework UIKit
-framework Foundation
-framework CoreGraphics
-framework GHUnitIOS
-force_load /Users/ops/tools/checker-269/lib/arc/libarclite_iphonesimulator.a
-framework Foundation
-lobjc
-lc++
-lSystem
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/build/Debug-iphonesimulator
-F/Applications/Xcode.app/Contents/Developer/Library/Frameworks
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/LibCoreMobileGHUnit
-F/Users/ops/workspace/MobileFramework_Test_IOS_Client/LibCoreMobile/ExternalFrameworks

所以这里有一些东西在运行 scan-build 时有所不同,它似乎使用了不同的链接器 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld vs /usr/llvm- gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld

在普通的 xcodebuild 中它有一个额外的选项 -demangle 并且在 scan-build 中它缺少两个 libclang 库

-lc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.profile_ios.a
-lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.ios.a

有谁知道我如何强制将库包含在“扫描构建”执行的链接器标志中。

4

0 回答 0