I am attempting to use OpenSSL’s SHA512 function in a C++ project of mine. In order to do this, I include openssl/sha.h in my source files that call SHA512 and link with the libeay32.lib library.
SHA512 is declared in openssl/sha.h as:
extern "C" {
//...
unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md);
//...
}
When linking, however, the symbol is not found:
mysql_sha.obj : error LNK2019: unresolved external symbol _SHA512 referenced in function _sha512
The problem appears to be that in libeay32.lib, the symbol for the function is actually SHA512 (no leading underscore), and I also see __imp_SHA512 when normally it would be __imp__SHA512.
I am using the Win64 build of OpenSSL 1.0.0d from Shining Light Productions.
Why would the symbol of the SHA512 function not have a leading underscore? How do I get around this problem?
There is only one calling convention for 64-bit code. None of the nonsense of
__cdecl,__stdcall,__fastcalletcetera. Whoever comes up with another x64 calling convention to save a fraction of a nanosecond is going to be summarily executed. Accordingly, DLL exports no longer have to be decorated with leading underscore and @ characters. The exported name is just plain SHA512.Unfortunately, that doesn’t explain why your compiler still prefixes an underscore. Sounds like you’re actually using a 32-bit compiler.