为 ARM64 构建时架构的未定义符号 x86_64

Undefined symbols for architecture x86_64 when building for ARM64

我构建了用于 ios 应用程序的 cryptopp 库。但没有用,只告诉我

"Undefined symbols for architecture x86_64:
"CryptoPP::ProxyFilter::IsolatedFlush(bool, bool)", referenced from: "

等等……

我遵循了 Crypopp wiki 页面的指南,但它仍然崩溃。

我该如何解决?

ld: warning: ignoring file [path]/libcryptopp.a, missing required architecture x86_64 in file [path]/libcryptopp.a (4 slices)CryptoPP::ProxyFilter::IsolatedFlush(bool, bool)", referenced from: ... ... ... (118 things)


我尝试使用 github's prebuilt cryptopp 构建,但它也不起作用。它会出现如下错误:

Undefined symbols for architecture arm64: "CryptoPP::BufferedTransformation::ChannelFlush(std::string const&, bool, int, bool)", referenced from:

 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::string const&, bool) const", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::Filter::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::string const&, bool)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::BufferedTransformation::ChannelPut2(std::string const&, unsigned char const*, unsigned long, int, bool)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::BufferedTransformation::ChannelCreatePutSpace(std::string const&, unsigned long&)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::BufferedTransformation::ChannelPutModifiable2(std::string const&, unsigned char*, unsigned long, int, bool)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::BufferedTransformation::ChannelMessageSeriesEnd(std::string const&, int, bool)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::BufferedTransformation::SetRetrievalChannel(std::string const&)", referenced from:

 vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o
 vtable for CryptoPP::Unflushable<CryptoPP::Filter> in MYCLASSBBB.o
 vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o
 vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o

"CryptoPP::StringSinkTemplate::StringSinkTemplate(std::string&)", referenced from:

 encryptString(std::string const&) in MYCLASSBBB.o
 decryptString(std::string const&, int) in MYCLASSBBB.o
 MYCLASSAAA::setDeviceId() in MYCLASSAAA.o
 MYCLASSAAA::getSignature() in MYCLASSAAA.o

ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

MYCLASSAAA 和 MYCLASSBBB 都是 类 使用 cryptopp 库的东西。

我会尝试自己构建库,但我认为可能会发生同样的错误。我该怎么办?

和项目设置 -- 我没有在 "Apple LLVM 6.0 - language" 处将 "Compile Sources As" 更改为 Objective-C++,我只是将其设置为 "According to File Type"。一定是objective-c++?当我更改为它时,它在其他来源中发生了太多错误。因为它是 cocos2d-x(0.12.0 / c++ 项目) 的遗留项目...

希望得到您的帮助。谢谢。

how can I fix that?

简答:运行 . ./setenv-ios.sh x86_64 下载脚本的新副本后。默认情况下,setenv-ios.sh 模拟器使用 i386,不支持 x86_64。该脚本现在响应 x86_64,因此获取一个新副本。

根据@rmaddy 在 的回答,似乎Xcode 6/iOS 8 SDK 在某些情况下使用x86_64 作为模拟器。

已上传 setenv-ios.sh 的新版本。它将通过使用 -arch x86_64 作为编译器选项选择 iPhoneSimulator.platform SDK 来响应 . ./setenv-ios.sh x86_64

iOS (Command Line) 的 Crpyto++ wiki 页面上添加了涵盖此内容的新部分。请参阅 模拟器、ARM64 和 x86_64 部分。

我解决了这个---简而言之,在构建 libcryptopp 时,它必须使用 -stdlib=libstdc++ 标志(到 GNUMAKEFILE 中的 CXXFLAGS)来构建。

因为我的项目是遗留 cocos2d-x 项目,所以标准库设置为 libstdc++。

更多信息是 。杰弗里非常详细地回答了我。