I am trying to implement one of the hash functions in Crypto++, and when I compile the following code:
1 2 3 4 5 6 7 8 9 10
|
#include <cryptopp/sha.h>
using namespace std;
int main( int argc, char* argv[] ) {
CryptoPP::SHA256 sha256gen;
byte hashb[256];
const byte word[256] = "test";
sha256gen.CalculateDigest(hashb, word, 4 );
return 0;
}
|
I get the following errors:
g++ -o dist/Debug/GNU-Linux-x86/longsight build/Debug/GNU-Linux-x86/md5.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/_ext/492155312/sha1.o
build/Debug/GNU-Linux-x86/main.o: In function `~HashTransformation':
/usr/include/cryptopp/cryptlib.h:532: undefined reference to `vtable for CryptoPP::HashTransformation'
build/Debug/GNU-Linux-x86/main.o: In function `SHA256':
/usr/include/cryptopp/sha.h:21: undefined reference to `vtable for CryptoPP::SHA256'
build/Debug/GNU-Linux-x86/main.o: In function `~SHA256':
/usr/include/cryptopp/sha.h:21: undefined reference to `vtable for CryptoPP::SHA256'
build/Debug/GNU-Linux-x86/main.o: In function `HashTransformation':
/usr/include/cryptopp/cryptlib.h:532: undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
/usr/include/cryptopp/cryptlib.h:532: undefined reference to `vtable for CryptoPP::HashTransformation'
build/Debug/GNU-Linux-x86/main.o: In function `CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 32u, CryptoPP::SHA256, 32u, true>::Init()':
/usr/include/cryptopp/iterhash.h:90: undefined reference to `CryptoPP::SHA256::InitState(unsigned int*)'
build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTVN8CryptoPP31IteratedHashWithStaticTransformIjNS_10EnumToTypeINS_9ByteOrderELi1EEELj64ELj32ENS_6SHA256ELj32ELb1EEE[vtable for CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 32u, CryptoPP::SHA256, 32u, true>]+0x30): undefined reference to `CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::Update(unsigned char const*, unsigned long)'
build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTVN8CryptoPP31IteratedHashWithStaticTransformIjNS_10EnumToTypeINS_9ByteOrderELi1EEELj64ELj32ENS_6SHA256ELj32ELb1EEE[vtable for CryptoPP::IteratedHashWithStaticTransform<unsigned int, CryptoPP::EnumToType<CryptoPP::ByteOrder, 1>, 64u, 32u, CryptoPP::SHA256, 32u, ...
I found someone else having the same problem back in 08 on this forum, and he said his solution was:
And for other people getting into the same problem, I had to tell the linker to link the libcrypto++.a library with object files. I assumed they would have been found automatically in usr/lib/ |
How would I go about doing this in Netbeans 7?
Edit: I am using Ubuntu Linux with the g++ toolchain...
I avoid messing with the linker/libraries whenever possible as it always ends up turning into a headache, but I need to learn sometime.
Thanks..