简体   繁体   English

VS2010中的多线程DLL中的Cryptopp

[英]Cryptopp in multi-threaded DLL, VS2010

I'm trying to use Cryptopp 5.6.2 on XPSP3 using VS 2010. New to this... 我正在尝试使用VS 2010在XPSP3上使用Cryptopp 5.6.2。

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] . 我需要使用多线程DLL,因为这是我的应用程序使用的DLL,因此我将Crypto ++项目属性中的所有引用从/MT[d]更改为/MD[d] All Crypto++ seems to build OK. 所有Crypto ++似乎都可以构建。

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). 但是,所有人都对我的C ++控制台应用程序不满意-我拥有标准的GetNewAndDeleteForCryptoPP ,并且似乎被称为OK(删除它,cryptoppp给出错误,包括它,并且cryptopp不打印警告)。

All seems fine until I add in the line PKCS5_PBKDF2_HMAC<SHA256> . 一切正常,直到我添加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) . 它可以很好地编译,但是会导致两个LNK2001错误,分别是CryptoPP::ThreadUserTimer::GetCurrentTimerValue(void)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 . 运行的想法在这里-我不能粘贴代码由于在我工作的地方神秘的规则,但我已经包括dll.hcryptlib.hosrng.haes.hsha.hhex.hinteger.hmodes.hpwdbased.h

Am I missing something blindingly obvious? 我错过了令人眼花obvious乱的明显东西吗?

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. CRYPTOPP_DLL添加到ThreadUserTimer中的hrtimer.h声明ThreadUserTimer hrtimer.h进行修复。

user1520427 provided you the answer. user1520427为您提供了答案。 You need to add CRYPTOPP_DLL for a few classes and functions. 您需要为一些类和函数添加CRYPTOPP_DLL

PKCS5_PBKDF2_HMAC<SHA256> is a header only implementation, so it does not need CRYPTOPP_DLL . PKCS5_PBKDF2_HMAC<SHA256>是仅标头的实现,因此不需要CRYPTOPP_DLL See pwdbased.h . 参见pwdbased.h

However, ThreadUserTimer is not header only, so you need to modify hrtimer.h : 然而, ThreadUserTimer 不仅是头,所以你需要修改hrtimer.h

OLD: 旧:

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

NEW: 新:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM