Undefined symbols for architecture x86_64 when building for ARM64

喜欢而已 提交于 2019-12-30 11:54:32

问题


I built the cryptopp lib to using for an ios application. but isn't working , only told me

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

and on and on...

and I follow the Crypopp wiki page's guideline, but it still crashing.

how can I fix that?

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)


I tried to build with github's prebuilt cryptopp but it doesn't work, too. it occur errors like below:

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)

the MYCLASSAAA and MYCLASSBBB are all of classes what using cryptopp lib.

I'll try to build the lib myself, but I think it maybe same errors happen. what I suppose to do?

and project settings -- I didn't changed "Compile Sources As" to Objective-C++ at "Apple LLVM 6.0 - language", I just setted that to "According to File Type". it must be objective-c++? when I change to that, it occur too many errors in another sources. because it is legacy project of cocos2d-x(0.12.0 / c++ project)...

I hope your help. thanks.


回答1:


how can I fix that?

Short answer: run . ./setenv-ios.sh x86_64 after downloading a new copy of the script. By default, setenv-ios.sh uses i386 for the simulator, and it did not support x86_64. The script now responds to x86_64, so fetch a new copy.

Based on @rmaddy's answer at Does Xcode 6 Simulator use x86_64?, it appears Xcode 6/iOS 8 SDK uses x86_64 for the simulator under some circumstances.

A new version of setenv-ios.sh was uploaded. It will respond to . ./setenv-ios.sh x86_64 by selecting the iPhoneSimulator.platform SDK using -arch x86_64 as a compiler option.

A new section covering this on the Crpyto++ wiki page for iOS (Command Line) was added. See the section Simulators, ARM64 and x86_64.




回答2:


I solved this--- in short, it have to build with -stdlib=libstdc++ flag(to CXXFLAGS in GNUMAKEFILE) when building libcryptopp.

because my project is legacy cocos2d-x project, that's standard library is setted to libstdc++.

more infomation is here. jeffrey answered me about this in great detail.



来源:https://stackoverflow.com/questions/28043785/undefined-symbols-for-architecture-x86-64-when-building-for-arm64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!