Thread: CryptoPP

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    69

    CryptoPP

    Hey I want start to using CryptoPP so I downloaded it from their site.

    I added to project lib which they provide and tried to run simple program:
    Code:
    // Key and IV setup
       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
       std::string plaintext = "Now is the time for all good men to come to the aid...";
       std::string ciphertext;
    
       // 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.data() ), plaintext.length() + 1 );
       stfEncryptor.MessageEnd();
    But It says :
    undefined reference to `CryptoPP::CipherModeFinalTemplate_ExternalCipher< CryptoPP::CBC_Encryption>::CipherModeFinalTemplate _ExternalCipher(CryptoPP::SimpleKeyedTransformatio n<CryptoPP::BlockTransformation>&, unsigned char const*, int)'|
    And much more undefined references to CryptoPP, what could I did wrong?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It's a linker error.

    You need to tell the compiler/linker where the CryptoPP lib is located and what it's name is.

    From a command line, it might look like
    g++ prog.cpp -L/path/to/lib -lcryptopp

    Where the full pathname of your library is
    /path/to/lib/libcryptopp.a

    From an IDE, something like project->settings->linker->additional libraries
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    69

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    69
    Is there something I should add to makefile ?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You could try adding absolute paths, rather than relative paths for everything.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed