将Objective-C应用程序链接到C静态库
发布时间:2020-12-15 01:48:03 所属栏目:百科 来源:网络整理
导读:我正在尝试使用Xcode构建一个链接静态C库的Objective-C桌面应用程序.我正在使用Apple的clang编译器.我收到以下链接器错误: Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)Target: x86_64-apple-darwin11.2.0Thread model: posi
我正在尝试使用Xcode构建一个链接静态C库的Objective-C桌面应用程序.我正在使用Apple的clang编译器.我收到以下链接器错误:
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn) Target: x86_64-apple-darwin11.2.0 Thread model: posix "/Developer/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.7.0 -syslibroot /Developer/SDKs/MacOSX10.7.sdk -o /Users/andrew/Library/Developer/Xcode/DerivedData/sl-marketplace-analysis-exomzzahbygseghhwoeclcvpooeo/Build/Products/Debug/sl marketplace analyitics.app/Contents/MacOS/sl marketplace analyitics -lcrt1.10.6.o -L/Users/andrew/Library/Developer/Xcode/DerivedData/sl-marketplace-analysis-exomzzahbygseghhwoeclcvpooeo/Build/Products/Debug -L/Users/andrew/Projects/sl-marketplace-analysis/platform/mac/sl marketplace analyitics/../../../../../Library/Developer/Xcode/DerivedData/sl-marketplace-analysis-exomzzahbygseghhwoeclcvpooeo/Build/Products/Debug -filelist /Users/andrew/Library/Developer/Xcode/DerivedData/sl-marketplace-analysis-exomzzahbygseghhwoeclcvpooeo/Build/Intermediates/sl marketplace analyitics.build/Debug/sl marketplace analyitics.build/Objects-normal/x86_64/sl marketplace analyitics.LinkFileList -framework Cocoa -lcore -lSystem /Developer/usr/bin/../lib/clang/3.0/lib/darwin/libclang_rt.osx.a -F/Users/andrew/Library/Developer/Xcode/DerivedData/sl-marketplace-analysis-exomzzahbygseghhwoeclcvpooeo/Build/Products/Debug Undefined symbols for architecture x86_64: "std::ios_base::Init::~Init()",referenced from: ___cxx_global_var_init in libcore.a(test.o) "std::ios_base::Init::Init()",referenced from: ___cxx_global_var_init in libcore.a(test.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 它似乎没有链接到C std库.这是问题所在,如果是这样,我如何确保它与之相关联? 更新: 如果我向构建添加一个空白的cpp文件,那么一切都编译并运行正常.我似乎只需要一种方法来告诉链接器链接C std库.我试过查看Xcode中的所有构建设置,但似乎找不到任何有用的东西. 解决方法
尝试添加-lstdc或-lc(取决于静态库期望的C运行时) 到“Build Setting”下的“Other Linker Flags”:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |