Guv*_*ven 23 iphone xcode linker-errors ios ios7
我在我的原生iOS应用程序(一堆.a库)中使用第三方框架.我的应用程序是使用XCode 5 base SDK 7.0开发的.
当部署目标为6.1(库和头搜索路径良好)时,库可以编译和链接.但是,当我将部署目标更改为7.0时,我收到以下链接器错误:
Undefined symbols for architecture i386:
"std::string::find_last_of(char const*, unsigned long) const", referenced from:
GetExecutionDir(ECTemplateString<char>&, char*, bool) in myLibrary.a(moPlatForm.o)
"std::string::find(char const*, unsigned long) const", referenced from:
ParseLog(std::string const&, unsigned int&, CmoDateTime&, int&, std::string&) in myLibrary.a(AppLog.o)
"std::string::size() const", referenced from:
mo::CmoParam::WriteToStream(void*, mo::STREAM_STATE*) in myLibrary.a(moParams.o)
"std::string::c_str() const", referenced from:
GetExecutionDir(ECTemplateString<char>&, char*, bool) in myLibrary.a(moPlatForm.o)
CMocaFileTransfer::UpdateParamsForGetTraceFiles(mo::CmoParamList&, long) in myLibrary.a(RobieFileTransfer.o)
CMocaFileTransfer::AddTraceFileForUpload(std::string const&, std::string const&) in myLibrary.a(RobieFileTransfer.o)
CMocaFileTransfer::CreateParamsForSendTraceFiles(mo::CmoObject&) in myLibrary.a(RobieFileTransfer.o)
mo::CmoParam::WriteToStream(void*, mo::STREAM_STATE*) in myLibrary.a(moParams.o)
ParseLog(std::string const&, unsigned int&, CmoDateTime&, int&, std::string&) in myLibrary.a(AppLog.o)
CAppLog::LogExists(unsigned int) in myLibrary.a(AppLog.o)
...
Run Code Online (Sandbox Code Playgroud)
库有点旧,我不确定是否存在兼容性问题.我不打算支持iOS 6,所以我需要将部署目标设置为7.0.任何形式的帮助/指导都会很棒.
Guv*_*ven 28
事实证明,如果XCode在项目中找不到任何C++文件,那么它假定不需要libstd ++.因此,您必须手动将C++文件添加到项目中(空的.mm文件就足够了).这是解决方案.
所有信用都在此Stackoverflow线程中转到此答案.
看起来myLibrary.a是使用C++代码调用构建的,并使用libstdc ++作为其C++标准库.您的应用程序项目可能会指定libc ++,可能是编译器的默认值.
尝试切换回libstdc ++并查看错误是否消失(或至少改变).您的最终解决方案可能是针对新标准库构建的库.