I think you need to add "-pthread" as an option to the linker. -------------------------------------------------- From: "Jojo" <[EMAIL PROTECTED]> Sent: Tuesday, May 20, 2008 1:21 PM To: "Crypto++ Users" <[EMAIL PROTECTED]> Subject: Re: Compiling fails "undefined reference to `pthread_key_create'"
> > Oops sorry. > > I am trying to compile an app which uses libcrypto++ on my debian > machine with gcc-4.2. > I googled it and some guys were facing this problem with Eclipse but I > am using KDevelop. > http://article.gmane.org/gmane.comp.encryption.cryptopp/3685 > http://groups.google.com/group/cryptopp-users/browse_thread/thread/e88323e6093f2c68?fwc=1 > > > This is my minimum program: > #include <iostream> > #include <cstdlib> > > //cryptopp > #include <md5.h> > #include <hex.h> > > using namespace std; > > int main(int argc, char *argv[]) > { > cout << "Hello, world!" << endl; > CryptoPP::MD5 hash; > byte digest[ CryptoPP::MD5::DIGESTSIZE ]; > std::string message = "abcdefghijklmnopqrstuvwxyz"; > > hash.Calculate#include <iostream> > #include <cstdlib> > #include <md5.h> > #include <hex.h> > using namespace std; > > int main(int argc, char *argv[]) > { > cout << "Hello, world!" << endl; > CryptoPP::MD5 hash; > byte digest[ CryptoPP::MD5::DIGESTSIZE ]; > std::string message = "abcdefghijklmnopqrstuvwxyz"; > > hash.CalculateDigest( digest, (byte*) message.c_str(), > message.length() ); > > CryptoPP::HexEncoder encoder; > std::string output; > encoder.Attach( new CryptoPP::StringSink( output ) ); > encoder.Put( digest, sizeof(digest) ); > encoder.MessageEnd(); > > std::cout << output << std::endl; > return EXIT_SUCCESS; > }Digest( digest, (byte*) message.c_str(), message.length() ); > > CryptoPP::HexEncoder encoder; > std::string output; > encoder.Attach( new CryptoPP::StringSink( output ) ); > encoder.Put( digest, sizeof(digest) ); > encoder.MessageEnd(); > > std::cout << output << std::endl; > return EXIT_SUCCESS; > } > > And this is the compiler output: > cd '/home/user/cryptopptest/debug' && WANT_AUTOCONF_2_5="1" > WANT_AUTOMAKE_1_6="1" LC_MESSAGES="C" LC_CTYPE="C" make -k > make all-recursive > Making all in src > cd /home/user/cryptopptest && /bin/sh /home/user/cryptopptest/missing > --run automake-1.10 --gnu src/Makefile > cd .. && /bin/sh ./config.status src/Makefile depfiles > config.status: creating src/Makefile > config.status: executing depfiles commands > g++ -DHAVE_CONFIG_H -I. -I/home/user/cryptopptest/src -I.. -I/usr/ > include/cryptopp -O0 -g3 -MT cryptopptest.o -MD -MP -MF .deps/ > cryptopptest.Tpo -c -o cryptopptest.o /home/user/cryptopptest/src/ > cryptopptest.cpp > In file included from /home/user/cryptopptest/src/cryptopptest.cpp:28: > /usr/include/cryptopp/md5.h:25:2: warning: #warning "You may be using > a weak algorithm that has been retained for backwards compatibility. > Please '#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1' before including > this .h file and prepend the class name with 'Weak::' to remove this > warning." > mv -f .deps/cryptopptest.Tpo .deps/cryptopptest.Po > /bin/sh ../libtool --tag=CXX --mode=link g++ -O0 -g3 -o cryptopptest > cryptopptest.o -lcryptopp > g++ -O0 -g3 -o cryptopptest cryptopptest.o /usr/lib/libcrypto++.so > /usr/lib/libcrypto++.so: undefined reference to `pthread_key_create' > /usr/lib/libcrypto++.so: undefined reference to `pthread_getspecific' > /usr/lib/libcrypto++.so: undefined reference to `pthread_key_delete' > /usr/lib/libcrypto++.so: undefined reference to `pthread_setspecific' > collect2: ld returned 1 exit status > make[2]: Nothing to be done for `all-am'. > make[2]: *** [cryptopptest] Error 1 > make[2]: Target `all' not remade because of errors. > make[1]: *** [all-recursive] Error 1 > make: *** [all] Error 2 > *** Exited with status: 2 *** > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [EMAIL PROTECTED] More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
