【问题标题】:Undefined architecture for armv7 - importing C librariesarmv7 的未定义架构 - 导入 C 库
【发布时间】:2015-01-06 22:33:10
【问题描述】:

我正在尝试在我的 iOS 项目中导入和使用 OpenSSL FIPS 验证的对象模块。当我构建项目时,我收到此错误消息:

Undefined symbols for architecture armv7:
"std::string::clear()", referenced from:
  +[CryptoUtilities getSeed:::] in CryptoUtilities.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
"___cxa_pure_virtual", referenced from:
  vtable for WBXML::CWBXMLParser in CWBXMLParser.o
"std::string::substr(unsigned long, unsigned long) const", referenced from:
  WBXML::CWBXMLParser::LoadWBXMLHeader(std::string const&, unsigned long, unsigned long&) in CWBXMLParser.o
  WBXML::CWBXMLParser::LoadTagContents(WBXML::CTag*, std::string const&, unsigned long, unsigned long&, unsigned short&, bool&) in CWBXMLParser.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
 "operator delete(void*)", referenced from:
  __gnu_cxx::new_allocator<WBXML::CTag>::deallocate(WBXML::CTag*, unsigned long) in CTag.o
    __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long) in CryptoUtilities.o

   // This goes for some more functions and then
 ld: symbol(s) not found for architecture armv7
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我知道这个问题已在here 提出并回答。我尝试了所有提到的解决方案,但无法解决此问题。

这是我试图解决问题的事情/设置。

  • 我已在链接的框架和库部分添加了库和容器。

  • 因为它是一个库,所以我没有要添加的任何 .m 文件。

  • 我尝试将 C++ 编译器更改为 Compiler Default、LLVM、GNU,但它们都不起作用。

  • 我尝试在其他链接器标志中添加 -ObjC。

  • 我在包含头文件时尝试了 extern C。头文件的定义也正确使用了extern C。

更新:

如下所述,我确实正确设置了编译器设置。

如果这对找出这个错误有任何帮助。正是在 runscript 阶段运行此脚本时,我得到了提到的这些错误。

https://docs.google.com/document/d/1YEebn2p8HKhc7lxUWa3xMHXWt1cELXLm3AoKElbEyuU/edit?usp=sharing

请帮帮我。

更新2:

xcrun -sdk iphoneos lipo -info CryptoUtilities.o 的输出是
非胖文件:CryptoUtilities.o 是架构:armv7

有关错误的更多详细信息: https://docs.google.com/document/d/1CqSa_tAsQP1JY_IxvXLDyYyQUI0iebV_REiCquwDXyk/edit?usp=sharing

请帮忙。我在这个职位上待了大约一个月。

【问题讨论】:

  • __gnu_cxx::... 来自 GNU C++ 运行时 (-stdlib=libstdc++)。您必须针对 LLVM C++ 运行时 (-stdlib=libc++) 编译 WBXML。如果库以相反的方式混合/匹配,那么您将收到有关缺少 __1::... 的错误
  • 另外,添加xcrun -sdk iphoneos lipo -info CryptoUtilities.o的输出。但看起来您没有使用正确的 C++ 运行时。
  • @jww 我将方言和库更改为(编译器默认值,编译器默认值)以及 libc++。它给了我同样的错误。还添加了上面 cmd 的输出。

标签: ios xcode openssl static-libraries fips


【解决方案1】:
"std::string::clear()", referenced from:
  +[CryptoUtilities getSeed:::] in CryptoUtilities.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
"___cxa_pure_virtual", referenced from:
  vtable for WBXML::CWBXMLParser in CWBXMLParser.o
"std::string::substr(unsigned long, unsigned long) const", referenced from:
  WBXML::CWBXMLParser::LoadWBXMLHeader(std::string const&, unsigned long, unsigned long&) in CWBXMLParser.o
  WBXML::CWBXMLParser::LoadTagContents(WBXML::CTag*, std::string const&, unsigned long, unsigned long&, unsigned short&, bool&) in CWBXMLParser.o
  +[CryptoUtilities getKey:::] in CryptoUtilities.o
 "operator delete(void*)", referenced from:
  __gnu_cxx::new_allocator<WBXML::CTag>::deallocate(WBXML::CTag*, unsigned long) in CTag.o
    __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long) in CryptoUtilities.o

这与 OpenSSL FIPS 对象模块无关。

___cxa_pure_virtual 和朋友是 C++ 运行时的一部分。看起来您正在混合和匹配 libc++(由 Xcode 使用)和 libstdc++(由 GNU 提供)。

由于 Xcode,您应该使用 libc++ 处理所有内容。这意味着您确保 -stdlib=libc++ 在所有命令行上。

如果你不能到处使用libc++,那么你需要到处使用libstdc++。 Xcode 设置如下所示C++ 标准库

上图是使用 libstdc++ 的 Crypto++(GNU 库,不是 Xcode 默认值)。虽然它是针对 Crypto++ 的问题,但它也适用于这里。

【讨论】:

  • 非常感谢。我已经用更多细节更新了这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-27
  • 2011-09-19
  • 1970-01-01
相关资源
最近更新 更多