Crypto++ Code::blocks Undefined reference problem
I'm trying to create a C++ program using Crypto++ (with C开发者_如何学Pythonode::Blocks), but keep getting stuck with the same problem. I'm using a cut-down version of this code : http://andreyvitdev.blogspot.com/2005/10/crypto-usage-sample.html , but I can't get it to compile.
#include "cryptopp/blowfish.h"
#include "cryptopp/osrng.h"
using namespace CryptoPP;
int main (int argc, char** argv) {
byte key[Blowfish::DEFAULT_KEYLENGTH],
iv[Blowfish::BLOCKSIZE];
AutoSeededRandomPool rng (true);
rng.GenerateBlock(key, sizeof (key));
rng.GenerateBlock(iv, sizeof (iv));
}
I get multiple errors, starting with : "C:\Users\Utilisateur\Programming\C++\CodeBlocks\Crytp tester\main.cpp|13|undefined reference to `CryptoPP::RandomNumberGenerator::GenerateBlock(unsigned char*, unsigned int)'"
Am I missing something? There are many references on different sites to libraries that must be imported, but I couldn't figure out where they were in the crypto++ folder : http://www.cryptopp.com/#download
"Undefined reference" is a linker error -- either you didn't build the Crypto++ library, or didn't tell the linker to link to it.
I'm not positive if it will build using MinGW (the most common compiler with Code Blocks) though. The Microsoft compilers (along with Visual Studio) are free; and are tested explicitly with both Code::Blocks and Crypto++.
精彩评论