Please see http://www.eskimo.com/~weidai/egcs.txt and then apply this patch if you get template errors while compiling Crypto++ 3.0. --- diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/config.h crypto-3.0/config.h --- ../import/crypto-3.0/config.h Fri Dec 18 19:17:54 1998 +++ crypto-3.0/config.h Thu Jan 14 08:32:33 1999 @@ -8,7 +8,12 @@ // define this if your compiler doesn't support namespaces #ifdef __GNUC__ -#define NO_NAMESPACE +//#define NO_NAMESPACE +#endif + +// define this if your compiler needs the external template. +#ifdef __GNUC__ +#define EXTERN_TEMPLATE extern #endif // switch between different secure memory allocation mechnisms, this is the only @@ -75,15 +80,23 @@ typedef unsigned int word; typedef unsigned long dword; #endif +/* We need it to do conversion. */ +union dword_union +{ + dword_union (const dword &d) { dw = d; } + dword dw; + word w [2]; +}; + const unsigned int WORD_SIZE = sizeof(word); const unsigned int WORD_BITS = WORD_SIZE * 8; #define LOW_WORD(x) (word)(x) #ifdef IS_LITTLE_ENDIAN -#define HIGH_WORD(x) (*(((word *)&(x))+1)) +#define HIGH_WORD(x) (((dword_union) (x)).w [1]) #else -#define HIGH_WORD(x) (*((word *)&(x))) +#define HIGH_WORD(x) (((dword_union) (x)).w [0]) #endif // if the above HIGH_WORD macro doesn't work (if you are not sure, compile it diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/luc.cpp crypto-3.0/luc.cpp --- ../import/crypto-3.0/luc.cpp Tue Dec 29 23:53:38 1998 +++ crypto-3.0/luc.cpp Thu Jan 14 08:30:12 1999 @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -template class OAEP; +EXTERN_TEMPLATE template class OAEP; INSTANTIATE_PUBKEY_TEMPLATES_MACRO(OAEP, PKCS_SignaturePaddingScheme, LUCFunction, InvertableLUCFunction); LUCFunction::LUCFunction(BufferedTransformation &bt) diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/oaepsha.cpp crypto-3.0/oaepsha.cpp --- ../import/crypto-3.0/oaepsha.cpp Wed Dec 31 16:00:00 1969 +++ crypto-3.0/oaepsha.cpp Thu Jan 14 08:31:09 1999 @@ -0,0 +1,17 @@ +// oaepsha.cpp - written and placed in the public domain by Wei Dai + +#include "config.h" + +#ifdef EXTERN_TEMPLATE +#include "pch.h" +#include "asn.h" +#include "nbtheory.h" +#include "sha.h" + +#include "pubkey.cpp" +#include "oaep.cpp" + +NAMESPACE_BEGIN(CryptoPP) +template class OAEP; +NAMESPACE_END +#endif diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/rabin.cpp crypto-3.0/rabin.cpp --- ../import/crypto-3.0/rabin.cpp Fri Dec 18 19:18:10 1998 +++ crypto-3.0/rabin.cpp Thu Jan 14 08:30:07 1999 @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -template class OAEP; +EXTERN_TEMPLATE template class OAEP; template class DecryptorTemplate, InvertableRabinFunction>; template class EncryptorTemplate, RabinFunction>; diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/rsa.cpp crypto-3.0/rsa.cpp --- ../import/crypto-3.0/rsa.cpp Fri Dec 18 19:18:12 1998 +++ crypto-3.0/rsa.cpp Thu Jan 14 08:30:01 1999 @@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP) INSTANTIATE_PUBKEY_TEMPLATES_MACRO(PKCS_EncryptionPaddingScheme, PKCS_SignaturePaddingScheme, RSAFunction, InvertableRSAFunction); -template class OAEP; +EXTERN_TEMPLATE template class OAEP; template class DecryptorTemplate, InvertableRSAFunction>; template class EncryptorTemplate, RSAFunction>; diff -x *.out --new-file -upr -x Makefile -x *.o ../import/crypto-3.0/xormac.h crypto-3.0/xormac.h --- ../import/crypto-3.0/xormac.h Sat Dec 12 14:23:50 1998 +++ crypto-3.0/xormac.h Wed Jan 13 09:40:19 1999 @@ -37,7 +37,7 @@ private: }; template XMACC::XMACC(const byte *userKey, word32 counter) - : IteratedHash(DATASIZE, T::DIGESTSIZE) + : IteratedHash(DATASIZE, T::DIGESTSIZE) , key(KEYLENGTH) , buffer(T::DIGESTSIZE/sizeof(HashWordType)) , counter(counter)