在Clion IDE中使用Crypto ++ [英] Using Crypto++ in Clion IDE

查看:475
本文介绍了在Clion IDE中使用Crypto ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在全新安装的Clion IDE中编译正确的应用程序时遇到一些问题。早些时候,我使用了Code :: Blocks并成功编译了所有代码。项目使用 pthread Crypto ++ 库。我已经在Ubuntu 15.04上安装了它们。并使用-pthread标志编译Clion项目。但是它找不到crypto ++库。

I have some problem with compile correct application in fresh-installed Clion IDE. Earlier I used Code::Blocks and all compiling successfully. Project use pthread and Crypto++ library. I'm already have them installed on my Ubuntu 15.04. And compile Clion project with -pthread flag. But it can't find crypto++ library. How to fix this?

我的CMake文件:

cmake_minimum_required(VERSION 3.3)
project(Chat)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")

set(SOURCE_FILES
    include/Chat.h
    include/Checker.h
    include/Client.h
    include/DataTransferingInterface.h
    include/EncryptorDES.h
    include/EncryptorRSA.h
    include/Logger.h
    include/OwnerClientInterface.h
    include/OwnerServerInterface.h
    include/Parser.h
    include/SecureChat.h
    include/Server.h
    src/Chat.cpp
    src/Checker.cpp
    src/Client.cpp
    src/DataTransferingInterface.cpp
    src/EncryptorDES.cpp
    src/EncryptorRSA.cpp
    src/Logger.cpp
    src/OwnerClientInterface.cpp
    src/OwnerServerInterface.cpp
    src/Parser.cpp
    src/SecureChat.cpp
    src/Server.cpp
    main.cpp)

add_executable(Chat ${SOURCE_FILES})

编译错误:

/usr/include/cryptopp/integer.h:26: undefined reference to `vtable for CryptoPP::Integer'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::AbstractRing<CryptoPP::Integer>::MultiplicativeGroupT::~MultiplicativeGroupT()':
/usr/include/cryptopp/algebra.h:70: undefined reference to `vtable for CryptoPP::AbstractRing<CryptoPP::Integer>::MultiplicativeGroupT'
/usr/include/cryptopp/algebra.h:70: undefined reference to `CryptoPP::AbstractGroup<CryptoPP::Integer>::~AbstractGroup()'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::FileStore::~FileStore()':
/usr/include/cryptopp/files.h:14: undefined reference to `vtable for CryptoPP::FileStore'
/usr/include/cryptopp/files.h:14: undefined reference to `vtable for CryptoPP::FileStore'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::FileSink::~FileSink()':
/usr/include/cryptopp/files.h:77: undefined reference to `vtable for CryptoPP::FileSink'
/usr/include/cryptopp/files.h:77: undefined reference to `vtable for CryptoPP::FileSink'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HMAC_Base::~HMAC_Base()':
/usr/include/cryptopp/hmac.h:12: undefined reference to `vtable for CryptoPP::HMAC_Base'
/usr/include/cryptopp/hmac.h:12: undefined reference to `vtable for CryptoPP::HMAC_Base'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::AlgorithmParametersTemplate<char const*>::AssignValue(char const*, std::type_info const&, void*) const':
/usr/include/cryptopp/algparam.h:313: undefined reference to `CryptoPP::g_pAssignIntToInteger'
/usr/include/cryptopp/algparam.h:313: undefined reference to `CryptoPP::g_pAssignIntToInteger'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptorBase<CryptoPP::ECPPoint>::Encrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/integer.h:118: undefined reference to `CryptoPP::Integer::One()'
/usr/include/cryptopp/integer.h:118: undefined reference to `CryptoPP::Integer::Zero()'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptorBase<CryptoPP::ECPPoint>::Encrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/pubkey.h:1228: undefined reference to `CryptoPP::Integer::One()'
/usr/include/cryptopp/pubkey.h:1228: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::RandomNumberGenerator&, CryptoPP::Integer const&, CryptoPP::Integer const&, CryptoPP::Integer::RandomNumberType, CryptoPP::Integer const&, CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::Pump2(unsigned long long&, bool)':
/usr/include/cryptopp/filters.h:763: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:763: undefined reference to `CryptoPP::FileStore::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::PumpMessages2(unsigned int&, bool)':
/usr/include/cryptopp/filters.h:765: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:765: undefined reference to `CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP::BufferedTransformation&, unsigned int&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::PumpAll2(bool)':
/usr/include/cryptopp/filters.h:767: undefined reference to `CryptoPP::DEFAULT_CHANNEL'
/usr/include/cryptopp/filters.h:767: undefined reference to `CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::BufferedTransformation&, std::string const&, bool)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::SourceTemplate<CryptoPP::FileStore>::SourceExhausted() const':
/usr/include/cryptopp/filters.h:769: undefined reference to `CryptoPP::BufferedTransformation::AnyRetrievable() const'
/usr/include/cryptopp/filters.h:769: undefined reference to `CryptoPP::BufferedTransformation::AnyMessages() const'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptionAlgorithm_Xor<CryptoPP::HMAC<CryptoPP::SHA1>, false>::SymmetricEncrypt(CryptoPP::RandomNumberGenerator&, unsigned char const*, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/gfpcrypt.h:439: undefined reference to `CryptoPP::xorbuf(unsigned char*, unsigned char const*, unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:441: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:442: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_EncryptionAlgorithm_Xor<CryptoPP::HMAC<CryptoPP::SHA1>, false>::SymmetricDecrypt(unsigned char const*, unsigned char const*, unsigned long, unsigned char*, CryptoPP::NameValuePairs const&) const':
/usr/include/cryptopp/gfpcrypt.h:470: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:471: undefined reference to `CryptoPP::HMAC_Base::Update(unsigned char const*, unsigned long)'
/usr/include/cryptopp/gfpcrypt.h:481: undefined reference to `CryptoPP::xorbuf(unsigned char*, unsigned char const*, unsigned char const*, unsigned long)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::ECPPoint, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::AgreeWithEphemeralPrivateKey(CryptoPP::DL_GroupParameters<CryptoPP::ECPPoint> const&, CryptoPP::DL_FixedBasePrecomputation<CryptoPP::ECPPoint> const&, CryptoPP::Integer const&) const':
/usr/include/cryptopp/pubkey.h:1445: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::ECPPoint, CryptoPP::EnumToType<CryptoPP::CofactorMultiplicationOption, 0> >::AgreeWithStaticPrivateKey(CryptoPP::DL_GroupParameters<CryptoPP::ECPPoint> const&, CryptoPP::ECPPoint const&, bool, CryptoPP::Integer const&) const':
/usr/include/cryptopp/pubkey.h:1473: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
/usr/include/cryptopp/pubkey.h:1473: undefined reference to `CryptoPP::Integer::Integer(CryptoPP::Integer const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HMAC<CryptoPP::SHA1>::HMAC(unsigned char const*, unsigned long)':
/usr/include/cryptopp/hmac.h:48: undefined reference to `CryptoPP::g_nullNameValuePairs'
/usr/include/cryptopp/hmac.h:48: undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned long, CryptoPP::NameValuePairs const&)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::P1363_KDF2<CryptoPP::SHA1>::DeriveKey(unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long)':
/usr/include/cryptopp/pubkey.h:506: undefined reference to `CryptoPP::P1363_MGF1KDF2_Common(CryptoPP::HashTransformation&, unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, bool, unsigned int)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 20u, CryptoPP::SHA1, 0u, false>::Init()':
/usr/include/cryptopp/iterhash.h:90: undefined reference to `CryptoPP::SHA1::InitState(unsigned int*)'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o:(.rodata._ZTIN8CryptoPP16IteratedHashBaseIjNS_18HashTransformationEEE[_ZTIN8CryptoPP16IteratedHashBaseIjNS_18HashTransformationEEE]+0x10): undefined reference to `typeinfo for CryptoPP::HashTransformation'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o:(.rodata._ZTIN8CryptoPP25SimpleKeyingInterfaceImplINS_9HMAC_BaseENS_4HMACINS_4SHA1EEEEE[_ZTIN8CryptoPP25SimpleKeyingInterfaceImplINS_9HMAC_BaseENS_4HMACINS_4SHA1EEEEE]+0x10): undefined reference to `typeinfo for CryptoPP::HMAC_Base'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::HashTransformation::HashTransformation(CryptoPP::HashTransformation const&)':
/usr/include/cryptopp/cryptlib.h:531: undefined reference to `vtable for CryptoPP::HashTransformation'
CMakeFiles/Chat.dir/src/EncryptorRSA.cpp.o: In function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 20u, CryptoPP::SHA1, 0u, false>::HashEndianCorrectedBlock(unsigned int const*)':
/usr/include/cryptopp/iterhash.h:89: undefined reference to `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'
collect2: error: ld returned 1 exit status
CMakeFiles/Chat.dir/build.make:406: recipe for target 'Chat' failed
make[2]: *** [Chat] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Chat.dir/all' failed
make[1]: *** [CMakeFiles/Chat.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


推荐答案

我在 CMakeLists.txt 中的 add_executable 之后执行了以下操作:问题:

I performed the following after add_executable in my CMakeLists.txt to resolve the issue:

target_link_libraries(Chat /usr/lib/libcrypto++.a)

这篇关于在Clion IDE中使用Crypto ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆