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

时间:2015-02-04 01:12:19

标签: c++ ios xcode cocos2d-x crypto++

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

  

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

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

&#34; CryptoPP :: Filter :: CopyRangeTo2(CryptoPP :: BufferedTransformation&amp ;, unsigned long long&amp ;, unsigned long long,std :: string const&amp;,bool)const&#34;,引自:

 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
     

&#34; CryptoPP :: Filter :: TransferTo2(CryptoPP :: BufferedTransformation&amp ;, unsigned long long&amp;,std :: string const&amp;,bool)&#34;,引自:

 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
     

&#34; CryptoPP :: BufferedTransformation :: ChannelPut2(std :: string const&amp;,unsigned char const *,unsigned long,int,bool)&#34;,引自:

 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
     

&#34; CryptoPP :: BufferedTransformation :: ChannelCreatePutSpace(std :: string const&amp;,unsigned long&amp;)&#34;,引自:

 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
     

&#34; CryptoPP :: BufferedTransformation :: ChannelPutModifiable2(std :: string const&amp;,unsigned char *,unsigned long,int,bool)&#34;,引自:

 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
     

&#34; CryptoPP :: BufferedTransformation :: ChannelMessageSeriesEnd(std :: string const&amp;,int,bool)&#34;,引自:

 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
     

&#34; CryptoPP :: BufferedTransformation :: SetRetrievalChannel(std :: string const&amp;)&#34;,引自:

 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
     

&#34; CryptoPP :: StringSinkTemplate :: StringSinkTemplate(std :: string&amp;)&#34;,引自:

 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       出口PATH =&#34; /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:在/ usr / bin中: / bin中:/ usr / sbin目录:/ sbin目录&#34;       /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/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 / Development / Office_Projects / PROJECTROOT / root / PROJECT_NAME / libs / cocos2dx / platform / third_party / ios / libraries -L / Users / USERNAME / Desktop / Development / Office_Projects / 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-aknkujy aqvqjswbhspmawywtyqee / 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 /中间体/ 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 Quart zCore -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/Build/Products/Release-iphoneos/PROJECT_NAME.app/PROJECT_NAME

和&#34; vtable for CRYPTOPP ::〜。o&#34;总是发生。通知:

  

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

1 个答案:

答案 0 :(得分:0)

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

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

符号在github's prebuilt cryptopp中定义(即我的github,顺便说一句)。以下是验证方法。

首先,从胖库中提取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<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, int, bool)

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

__1libc++(LLVM)用于区分libstdc++(GNU)的内容。 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >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<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) const

这可以改写为:

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

-----

IF 你需要GNU&#39; libstdc++,然后你可以自己构建它。以下是步骤:

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

    我下载了Cocos2D-x并试图查看它的配置(我不是Cmake的家伙,所以我可能错了以下内容)。它在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&#39; libc++。但它也使用-std=c++11,而GitHub项目没有使用它。但我不确定-std=c++11在这里会有所作为。

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


    如果感兴趣,__1是用于版本控制的内联命名空间。请参阅What are inline namespaces for?Where does the __1 symbol come from when using LLVM's libc++?