Having a bit of a problem with Microsoft's Visual C++ and Crypto++. 

My project was originally written on linux using gcc and such. I've just 
finished porting it to Windows, and while it compiles fine, I'm getting some 
linker errors. Specifically:

<errors>
cryptlib.lib(cryptlib.obj) : error LNK2005: "void __cdecl 
CryptoPP::UnalignedPutWord(enum CryptoPP::ByteOrder,unsigned char*, unsigned 
char const*)" ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]) 
already defined in cryptopp.obj
...
../../Release_TS/php_cryptopp.dll : fatal error LNK1169: one or more multiply 
defined symbols found
Error executing link.exe

php_cryptopp.dll -- 2 error(s), 1 warning(s)
</errors>

As a work around, I used the /force option in the linker settings, which 
downgrades the error to a warning and everything links. The resulting dll 
even works fine and passes all of the standard tests and such, which were 
mostly borrowed from the cryptest.exe tests. (All of the .dat files are used 
and produce the output equivalent to "cryptest.exe -v".)

As I'm not overly familiar with VC++ and most of my work is done on UNIX 
systems, could somebody more familiar with VC++ offer any advice? I'm 
assuming that I might be #including misc.h in multiple places within 
cryptopp.cpp, which produces cryptopp.obj. 

My project uses pretty much the same settings as cryptest.exe and cryptlib.lib 
from the Crypto++ 5.0 VC++ project files, with the exception that I compiled 
cryptlib.lib to use Multithreaded DLL as the runtime library to match my 
project. 

Since the resulting DLL works fine, I'm not overly worried, but if anybody has 
a clue what's going on here, I'm all ears. (I believe that Borland's and 
gcc's linkers quietly ignore the problem by ignoring anything after the first 
definition of a function/class/whatever, but VC++ seems a bit stricter in 
this case.)

Thanks to anyone who can help. If anybody would like to look at the source 
code for my project, I'll be posting it to http://www.tutorbuddy.com/software 
some time within the next few days, possibly later on tonight. (I don't have 
a minimal example of the problem quite yet.)

J

Reply via email to