CryptoPP

This is a discussion on CryptoPP within the C++ Programming forums, part of the General Programming Boards category; Hey I want start to using CryptoPP so I downloaded it from their site. I added to project lib which ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21