gpt4 book ai didi

c++ - Crypto++/iOS 64 位项目中的 undefined symbol

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:24 27 4
gpt4 key购买 nike

我尝试使用 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 库的类。它使用 cryptlib.h、modes.h、filters.h、aes.h、base64.h、md5.h、hex.h。

我什至尝试自己构建库,但我还是遇到了同样的错误。我该怎么办?

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


添加 xcode 命令

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/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-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/Build/Products/Release-iphoneos/PROJECT_NAME.app/PROJECT_NAME

和“vtable for CRYPTOPP::~.o”总是会发生。附上通知:

NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

最佳答案

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,顺便说一句)。以下是验证方法。

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

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

__1是什么libc++ (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)

我们可以对第二个有问题的 child 重复,它遵循相同的模式( 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

-----

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

  1. 从网站下载并解压 Crypto++
  2. 下载解压 cryptopp-mobile.zip .在 Crypto++ 源文件之上解压它
  3. 打开新的GNUmakefile , 通过搜索以 IS_IOS 开头的 block 找到 iOS 规则
  4. 更改 IS_IOS 中的这一行 block :CXXFLAGS += -stdlib=libc++ .将其更改为 CXXFLAGS += -stdlib=libstdc++
  5. 做交叉编译...

-----

我下载了 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 的 libc++ .但它也使用 -std=c++11 ,并且 GitHub 项目没有使用它。但我不确定-std=c++11在这里有所作为。

只是自行车脱落,但这是一个不好的迹象:_SCL_SECURE_NO_WARNINGS .如果他们公然这样做,那么他们可能有不同程度的不良和 splinter 。 (只是我在审计软件方面的经验)。


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

关于c++ - Crypto++/iOS 64 位项目中的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28311795/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com