xcode 部署目标为 7.0 时架构错误的未定义符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19271856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:03:35  来源:igfitidea点击:

Undefined symbols for architecture error when deployment target is 7.0

iphoneiosxcodeios7linker-errors

提问by Guven

I am using third party frameworks in my native iOS application (bunch of .a libraries). My application is developed with XCode 5 base SDK 7.0.

我在我的原生 iOS 应用程序(一堆 .a 库)中使用第三方框架。我的应用程序是使用 XCode 5 基础 SDK 7.0 开发的。

The libraries compile and link fine when the deployment target is 6.1 (library and header search paths are good). However, when I change the deployment target to be 7.0, I get the following linker error:

当部署目标为 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)
      ...

Libraries are a bit old, I am not sure if there is a compatibility issue. I am not planning to support iOS 6 so I need to set the deployment target as 7.0. Any kind of help/direction would be great.

库有点旧,我不确定是否存在兼容性问题。我不打算支持 iOS 6,所以我需要将部署目标设置为 7.0。任何形式的帮助/指导都会很棒。

回答by Denis

for me, including the 'stdc++.6.0.9.dylib' instead of 'stdc++.dylib' into the dependencies resolved the linker errors too

对我来说,在依赖项中包含“ stdc++.6.0.9.dylib”而不是“ stdc++.dylib”也解决了链接器错误

回答by Guven

It turns out that if XCode can't find any C++ files in the project, then it assumes that libstd++ is not required. So, you have to manually add a C++ file to the project (an empty .mm file would be enough). That is the solution.

事实证明,如果 XCode 在项目中找不到任何 C++ 文件,则它假定不需要 libstd++。因此,您必须手动将 C++ 文件添加到项目中(一个空的 .mm 文件就足够了)。这就是解决方案。

All the credits go to this answerin this Stackoverflow thread.

所有学分去这个答案在此#1线

回答by Phillip Mills

It looks as if myLibrary.a was built with calls to C++ code and used libstdc++ as its C++ standard library. Your application project probably specifies libc++ instead, perhaps as the compiler default.

看起来 myLibrary.a 是通过调用 C++ 代码构建的,并使用 libstdc++ 作为其 C++ 标准库。您的应用程序项目可能会指定 libc++,也许作为编译器默认值。

Try switching back to libstdc++ and see if the errors go away (or change, at least). Your eventual solution is likely to be a library that's built against the new standard library.

尝试切换回 libstdc++ 并查看错误是否消失(或至少发生变化)。您最终的解决方案很可能是一个针对新标准库构建的库。