Nicko
Nicko

Reputation: 195

Cryptopp in multi-threaded DLL, VS2010

I'm trying to use Cryptopp 5.6.2 on XPSP3 using VS 2010. New to this...

I need to use the mult-threading DLLs as that is what my application uses, so I changed all references in the Crypto++ project properties from /MT[d] to /MD[d]. All Crypto++ seems to build OK.

However, all is not happy with my C++ console app - I have the standard GetNewAndDeleteForCryptoPP and that seems to be called OK (remove it and cryptopp gives an error, include it and cryptopp doesn't print warnings).

All seems fine until I add in the line PKCS5_PBKDF2_HMAC<SHA256>. It compiles fine but causes two LNK2001 errors for unresolved symbols for CryptoPP::ThreadUserTimer::GetCurrentTimerValue(void) and CryptoPP::ThreadUserTimer::TicksPerSecond(void).

Running out of ideas here - I can't paste the code due to arcane rules at the place I work, however I have included dll.h, cryptlib.h, osrng.h, aes.h, sha.h, hex.h, integer.h, modes.h and pwdbased.h.

Am I missing something blindingly obvious?

Upvotes: 2

Views: 797

Answers (2)

jww
jww

Reputation: 102205

user1520427 provided you the answer. You need to add CRYPTOPP_DLL for a few classes and functions.

PKCS5_PBKDF2_HMAC<SHA256> is a header only implementation, so it does not need CRYPTOPP_DLL. See pwdbased.h.

However, ThreadUserTimer is not header only, so you need to modify hrtimer.h:

OLD:

00042 class ThreadUserTimer : public TimerBase
00043 {
00044    ...
00048 };

NEW:

00042 class CRYPTOPP_DLL ThreadUserTimer : public TimerBase
00043 {
00044     ...
00048 };

Upvotes: 1

user1520427
user1520427

Reputation: 1365

I was having this issue too, it doesn't look like that class is being exported. Adding CRYPTOPP_DLL to the declaration of ThreadUserTimer in hrtimer.h will fix it.

Upvotes: 2

Related Questions