创建密文时出现Crypto ++错误

时间:2014-04-07 17:10:23

标签: c++ build crypto++

我是C ++的新手,我需要使用Crypto ++。我一直在寻找解释如何使用它的例子。我找到了Example of AES using Crypto++。我认为这很棒......唯一的问题是当我尝试构建它时,我会遇到一堆错误!

首先,我必须更改头文件的包含路径。我不知道为什么,但是当我没有在路径前添加“crypto ++”时,它找不到头文件。另一篇文章建议使用它,它似乎使错误消失。

如果你想看到我想要构建的代码,它就在这里:

#include <iostream>
#include <string>
#include <iomanip>

#include "crypto++/modes.h"
#include "crypto++/aes.h"
#include "crypto++/filters.h"
using namespace std;
int main(int argc, char* argv[]) {

    //
    // Key and IV setup
    //AES encryption uses a secret key of a variable length (128-bit, 196-bit or 256-   
    //bit). This key is secretly exchanged between two parties before communication   
    //begins. DEFAULT_KEYLENGTH= 16 bytes
    byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[ CryptoPP::AES::BLOCKSIZE ];
    memset( key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH );
    memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE );

    //
    // String and Sink setup
    //
    string plaintext = "Now is the time for all good men to come to the aide...";
    string ciphertext;
    string decryptedtext;

    //
    // Dump Plain Text
    //
    cout << "Plain Text (" << plaintext.size() << " bytes)" << endl;
    cout << plaintext;
    cout << endl << endl;

    // //
    // // Create Cipher Text
    // //
    CryptoPP::AES::Encryption aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, iv );

    CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext ) );
    stfEncryptor.Put( reinterpret_cast<const unsigned char*>( plaintext.c_str() ), plaintext.length() + 1 );
    stfEncryptor.MessageEnd();

    //
    // Dump Cipher Text
    //
    cout << "Cipher Text (" << ciphertext.size() << " bytes)" << endl;

    for( int i = 0; i < ciphertext.size(); i++ ) {

        cout << "0x" << hex << (0xFF & static_cast<byte>(ciphertext[i])) << " ";
    }

    cout << endl << endl;

    //
    // Decrypt
    //
    CryptoPP::AES::Decryption aesDecryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv );

    CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink( decryptedtext ) );
    stfDecryptor.Put( reinterpret_cast<const unsigned char*>( ciphertext.c_str() ), ciphertext.size() );
    stfDecryptor.MessageEnd();

    //
    // Dump Decrypted Text
    //
    cout << "Decrypted Text: " << endl;
    cout << decryptedtext;
    cout << endl << endl;

    return 0;
}

这些是我得到的错误

/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::~SimpleKeyingInterface()':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceD2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceD5Ev]+0xb): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2Ev[_ZN8CryptoPP21SimpleKeyingInterfaceC5Ev]+0x8): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::~BlockTransformation()':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationD2Ev[_ZN8CryptoPP19BlockTransformationD5Ev]+0xb): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::~Base()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0xc): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseD2Ev[_ZN8CryptoPP8Rijndael4BaseD5Ev]+0x16): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::~Enc()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0xb): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncD2Ev[_ZN8CryptoPP8Rijndael3EncD5Ev]+0x15): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::BlockTransformation()':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x15): undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2Ev[_ZN8CryptoPP19BlockTransformationC5Ev]+0x1e): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::Base()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x17): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2Ev[_ZN8CryptoPP8Rijndael4BaseC5Ev]+0x21): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::Enc()':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x16): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2Ev[_ZN8CryptoPP8Rijndael3EncC5Ev]+0x20): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>::BlockCipherFinal(unsigned char const*, unsigned int)':
AES.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhj[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhj]+0x27): undefined reference to `CryptoPP::g_nullNameValuePairs'
AES.cpp:(.text._ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC2EPKhj[_ZN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEC5EPKhj]+0x44): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x44): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x50): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x54): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x78): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x80): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEE[vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>]+0x90): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x44): undefined reference to `CryptoPP::Rijndael::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x50): undefined reference to `CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x54): undefined reference to `CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x74): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x7c): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x8c): undefined reference to `non-virtual thunk to CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x70): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP15BlockCipherImplINS_13Rijndael_InfoENS_11BlockCipherEEE[vtable for CryptoPP::BlockCipherImpl<CryptoPP::Rijndael_Info, CryptoPP::BlockCipher>]+0x80): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x6c): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP13AlgorithmImplINS_25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES5_EES6_EE[vtable for CryptoPP::AlgorithmImpl<CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >, CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> > >]+0x7c): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP25SimpleKeyingInterfaceImplINS_8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEES4_EE[vtable for CryptoPP::SimpleKeyingInterfaceImpl<CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>, CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info> >]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP8TwoBasesINS_11BlockCipherENS_13Rijndael_InfoEEE[vtable for CryptoPP::TwoBases<CryptoPP::BlockCipher, CryptoPP::Rijndael_Info>]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x24): undefined reference to `CryptoPP::SimpleKeyingInterface::SetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x3c): undefined reference to `CryptoPP::SimpleKeyingInterface::GetNextIV(CryptoPP::RandomNumberGenerator&, unsigned char*)'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x68): undefined reference to `CryptoPP::BlockTransformation::OptimalDataAlignment() const'
/tmp/cczoSf1S.o:(.rodata._ZTVN8CryptoPP11BlockCipherE[vtable for CryptoPP::BlockCipher]+0x78): undefined reference to `CryptoPP::BlockTransformation::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned int, unsigned int) const'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8Rijndael3EncEEES4_EE[typeinfo for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>]+0x8): undefined reference to `typeinfo for CryptoPP::Rijndael::Enc'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP11BlockCipherE[typeinfo for CryptoPP::BlockCipher]+0x10): undefined reference to `typeinfo for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o:(.rodata._ZTIN8CryptoPP11BlockCipherE[typeinfo for CryptoPP::BlockCipher]+0x18): undefined reference to `typeinfo for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface(CryptoPP::SimpleKeyingInterface const&)':
AES.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2ERKS0_[_ZN8CryptoPP21SimpleKeyingInterfaceC5ERKS0_]+0x8): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/cczoSf1S.o: In function `CryptoPP::BlockTransformation::BlockTransformation(CryptoPP::BlockTransformation const&)':
AES.cpp:(.text._ZN8CryptoPP19BlockTransformationC2ERKS0_[_ZN8CryptoPP19BlockTransformationC5ERKS0_]+0x1d): undefined reference to `vtable for CryptoPP::BlockTransformation'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Base::Base(CryptoPP::Rijndael::Base const&)':
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2ERKS1_[_ZN8CryptoPP8Rijndael4BaseC5ERKS1_]+0x1e): undefined reference to `vtable for CryptoPP::Rijndael::Base'
AES.cpp:(.text._ZN8CryptoPP8Rijndael4BaseC2ERKS1_[_ZN8CryptoPP8Rijndael4BaseC5ERKS1_]+0x28): undefined reference to `vtable for CryptoPP::Rijndael::Base'
/tmp/cczoSf1S.o: In function `CryptoPP::Rijndael::Enc::Enc(CryptoPP::Rijndael::Enc const&)':
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2ERKS1_[_ZN8CryptoPP8Rijndael3EncC5ERKS1_]+0x1d): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
AES.cpp:(.text._ZN8CryptoPP8Rijndael3EncC2ERKS1_[_ZN8CryptoPP8Rijndael3EncC5ERKS1_]+0x27): undefined reference to `vtable for CryptoPP::Rijndael::Enc'
collect2: ld returned 1 exit status
[Finished in 0.7s with exit code 1]
[shell_cmd: g++ "/home/jack/Desktop/Crytpo C++/AES.cpp" -o "/home/jack/Desktop/Crytpo C++/AES"]
[dir: /home/jack/Desktop/Crytpo C++]
[path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]

我尝试一次放入1行,然后构建,似乎开始在创建密文时遇到错误。

1 个答案:

答案 0 :(得分:2)

你如何编译你的项目?看来你没有链接crypto ++库。如果您使用的是gcc,可以添加-lcrypto ++来编译选项。