Crypto ++ / iOS 64位项目中未定义的符号

我尝试使用github预先构建的cryptopp构建,但它也不起作用。 它会发生如下错误:

架构arm64的未定义符号:“CryptoPP :: BufferedTransformation :: ChannelFlush(std :: string const&,bool,int,bool)”,引自:

vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o vtable for CryptoPP::Bufferless in MYCLASSBBB.o 

“CryptoPP :: Filter :: CopyRangeTo2(CryptoPP :: BufferedTransformation&,unsigned long long&,unsigned long long,std :: string const&,bool)const”,引用自:

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

“CryptoPP :: Filter :: TransferTo2(CryptoPP :: BufferedTransformation&,unsigned long long&,std :: string const&,bool)”,引自:

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

“CryptoPP :: BufferedTransformation :: ChannelPut2(std :: string const&,unsigned char const *,unsigned long,int,bool)”,引自:

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

“CryptoPP :: BufferedTransformation :: ChannelCreatePutSpace(std :: string const&,unsigned long&)”,引自:

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

“CryptoPP :: BufferedTransformation :: ChannelPutModifiable2(std :: string const&,unsigned char *,unsigned long,int,bool)”,引自:

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

“CryptoPP :: BufferedTransformation :: ChannelMessageSeriesEnd(std :: string const&,int,bool)”,引自:

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

“CryptoPP :: BufferedTransformation :: SetRetrievalChannel(std :: string const&)”,引自:

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

“CryptoPP :: StringSinkTemplate :: StringSinkTemplate(std :: string&)”,引自:

  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:找不到架构arm64 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)

MYCLASSAAA和MYCLASSBBB都是使用cryptopp lib的所有类。 它使用cryptlib.h,modes.h,filters.h,aes.h,base64.h,md5.h,hex.h。

我甚至试图自己构建lib,但是我发生了同样的错误。 我该怎么办?

我希望你的帮助。 谢谢。


添加xcode cmd

Ld /Users/USERNAME/Library/Developer/Xcode/DerivedData/PROJECT_NAME-aknkujyaqvqjswbhspmawywtyqee/Build/Products/Release-iphoneos/PROJECT_NAME.app/PROJECT_NAME normal arm64 cd / Users / USERNAME / Desktop / Development / Office_Projects / PROJECTROOT / root export IPHONEOS_DEPLOYMENT_TARGET = 5.1.1 export PATH =“/ Applications / Xcode.app / Contents / Developer / Platforms / iPhoneOS.platform / Developer / usr / bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/ usr / bin :/ bin:/ usr / sbin:/ sbin“/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/平台/ iPhoneOS.platform / Developer / SDKs / iPhoneOS8.1.sdk -L / Users / USERNAME / Library / Developer / Xcode / DerivedData / PROJECT_NAME-aknkujyaqvqjswbhspmawywtyqee / Build / Products / Release-iphoneos -L / Users / USERNAME / Desktop /开发/ Office_Projects / PROJECTROOT / root / PROJECT_NAME / libs / cocos2dx / platform / third_party / ios / libraries -L / Users / USERNAME / Desktop / Development / Office_Project s / PROJECTROOT / root / PROJECT_NAME / libs / EEAF-SDK7.0(i386,armv7,armv7s,arm64)-L / Users / USERNAME / Desktop / Development / Office_Projects / PROJECTROOT / root / PROJECT_NAME / libs / boost_1_57 / ios -L / Users / USERNAME / Desktop / Development / Office_Projects / PROJECTROOT / root / PROJECT_NAME / Classes / cryptopp / lib -LPROJECT_NAME / cocos2dx / platform / third_party / ios / libraries -LPROJECT_NAME / EEAF-SDK7.0(i386,armv7,armv7s,arm64 )-F / Users / USERNAME / Library / Developer / Xcode / DerivedData / PROJECT_NAME-aknkujyaqvqjswbhspmawywtyqee / Build / Products / Release-iphoneos -F / Users / USERNAME / Desktop / Development / Office_Projects / PROJECTROOT / root / PROJECT_NAME / libs -filelist / Users / USERNAME / Library / Developer / Xcode / DerivedData / PROJECT_NAME-aknkujyaqvqjswbhspmawywtyqee / Build / Intermediates / PROJECT_NAME.build / Release-iphoneos / PROJECT_NAME.build / Objects-normal / arm64 / PROJECT_NAME.LinkFileList -dead_strip -lxml2 -lz -ObjC – lcryptopp -fobjc-link-runtime -miphoneos-version-min = 5.1.1 -lc ++ / Users / USERNAME / Desktop / Development / Office_Projects / PROJECTROOT / root /PROJECT_NAME/libs/boost_1_57/ios/boost.a-framework UIKit -framework CoreTelephony -lEEAF -framework FacebookSDK -framework AddressBook -framework AddressBookUI -framework AudioToolbox -framework AVFoundation -framework CFNetwork -framework CoreGraphics -framework CoreLocation -framework CoreMedia -framework CoreText -framework Foundation-framework ImageIO -framework MediaPlayer -framework MobileCoreServices -framework OpenAL -framework OpenGLES -framework QuartzCore -framework Security -framework SystemConfiguration -lsqlite3.0 -framework StoreKit -lcurl -Xlinker -dependency_info -Xlinker / Users / USERNAME / Library / Developer /Xcode/DerivedData/PROJECT_NAME-aknkujyaqvqjswbhspmawywtyqee/Build/Intermediates/PROJECT_NAME.build/Release-iphoneos/PROJECT_NAME.build/Objects-normal/arm64/PROJECT_NAME_dependency_info.dat -o / Users / USERNAME / Library / Developer / Xcode / DerivedData / PROJECT_NAME -aknkujyaqvqjswbhspmawywtyqee /编译/产品/释放-的iPhoneOS / PROJECT_NAME.app / PROJECT_NAME

和“vtable for CRYPTOPP ::〜。o”总是会发生。 通知:

注意:缺少vtable通常意味着第一个非内联虚拟成员函数没有定义。

 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 in MYCLASSBBB.o 

认为没有使用libc++ ,它是LLVM的C ++标准库。 我认为因为我没有看到-stdlib=libc++ (但我不记得是否直接传递给ld )。

符号在github的预建的cryptopp (这是我的github,顺便说一句)中定义。 以下是validation方法。

首先,从fat库中提取arm64库:

 $ xcrun -sdk iphoneos lipo libcryptopp.a -thin arm64 -output libcryptopp-arm64.a $ ls libcryptopp-arm64.a libcryptopp.a 

接下来,使用nm来转储全局符号,并使用c++filt来解码:

 $ nm -g libcryptopp-arm64.a | c++filt | grep BufferedTransformation::ChannelFlush | grep " T " 0000000000002110 T CryptoPP::BufferedTransformation::ChannelFlush(std::__1::basic_string, std::__1::allocator > const&, bool, int, bool) 

国会大厦T意味着您正在搜索已定义和导出的符号。 较低的t表示其定义但未导出 – 即私有。 国会大厦U意味着它未定义。

__1libc++ (LLVM)用来区分libstdc++ (GNU)的东西。 std::__1::basic_string, std::__1::allocator >是一个string ,因此可以重写为:

 CryptoPP::BufferedTransformation::ChannelFlush(std::__1::string const&, bool, int, bool) 

如果这个库是针对libstdc++ (GNU)构建的,那么库中的符号将是:

 CryptoPP::BufferedTransformation::ChannelFlush(std:::string const&, bool, int, bool) 

我们可以重复第二个问题子,它遵循相同的模式( libc++ ,而不是libstdc++ ):

 $ nm -g libcryptopp-arm64.a | c++filt | grep CryptoPP::Filter::CopyRangeTo2 | grep " T " 00000000000001c4 T CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::__1::basic_string, std::__1::allocator > const&, bool) const 

这可以改写为:

 CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::__1::string const&, bool) const 

—–

如果您需要GNU的libstdc++ ,那么您可以自己构建它。 以下是步骤:

  1. 从网站下载并解压缩Crypto ++
  2. 下载并解压缩cryptopp-mobile.zip 。 将其解压缩到Crypto ++源文件的顶部
  3. 打开新的GNUmakefile ,通过搜索以IS_IOS开头的块来查找iOS规则
  4. IS_IOS块中更改此行: CXXFLAGS += -stdlib=libc++ 。 将其更改为CXXFLAGS += -stdlib=libstdc++
  5. 做交叉编译……

—–

我下载了Cocos2D-x并尝试查看它的配置(我不是Cmake的家伙,所以我可能错了以下内容)。 它在CmakeList.txt有以下CmakeList.txt

 if(MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 -wd4514 -wd4056 -wd4996 -wd4099) else() set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -std=c99") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11 -Wno-deprecated-declarations -Wno-reorder") if(CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif(MSVC) 

如果 Cmake正在做我怀疑的事情,那么它使用LLVM的libc++ 。 但它也使用-std=c++11 ,而GitHub项目没有使用它。 但我不确定-std=c++11在这里-std=c++11

只是自行车脱落,但这是一个坏兆头: _SCL_SECURE_NO_WARNINGS 。 如果他们公然这样做,那么他们可能会有各种程度的不良和破碎。 (只是我对审计软件的经验)。


如果感兴趣, __1是用于版本控制的内联命名空间。 请参阅什么是内联命名空间? 当使用LLVM的libc ++时,__1符号来自何处? 。

Interesting Posts