【发布时间】: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