Crypto++ 库 link 使用 Visual Studio 2017 时出错

Crypto++ library link error using Visual Studio 2017

我正在尝试在我的项目(windows 应用程序)中使用 Crypto++ 库。使用它,包含,编译工作正常,但无法处理 link 错误

这里是一些link错误的例子,还有更多,但不要认为复制粘贴所有错误是有意义的

error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::encrypt(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?encrypt@CryptoV2@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z) referenced in function "public: void __thiscall PStore::storeReversibleCrypt(wchar_t *,char *)" (?storeReversibleCrypt@PStore@@QAEXPA_WPAD@Z)
error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::hashPassword(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?hashPassword@CryptoV2@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@0@Z)

fatal error LNK1120: 4 unresolved externals

基本上,我将 crypto++ 的 "Win32\Output\Release" 目录添加到我的 link er 的附加库目录属性中,并将主文件夹添加到我的 C/C++ 的 General 的 属性 "Additional Include Directories"

我尝试了很多想法,比如将库添加为新项目(同样的错误),将所有 cpp 文件添加到我的项目并用它编译(不编译),只添加 .cpp 文件我是使用(不现实,太多),linking cryptopp610 版本的所有不同文件夹(cryptdll、cryptlib、dll_output、输出、相同的错误),现在,我真的不知道还有什么我可以试试。我也做了很多搜索,尝试了我看到的所有解决方案(不记得所有的解决方案),仍然是同样的问题。我还尝试创建一个新项目来添加 crypto++ 而无需长时间编译或神秘问题,但我也遇到 linker 错误。

有没有人有什么建议可以帮助我?无论如何,非常感谢,请原谅我的英语

编辑:需要在新的空白项目中添加它,我得到 63 个未解析的外部符号,所以我想我忘了做一些基本的事情,但想不通其中

可能是Ws2_32.lib链接器中缺少

error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::encrypt(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?encrypt@CryptoV2@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z) referenced in function "public: void __thiscall PStore::storeReversibleCrypt(wchar_t *,char *)" (?storeReversibleCrypt@PStore@@QAEXPA_WPAD@Z)
error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::hashPassword(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?hashPassword@CryptoV2@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@0@Z)

缺失的符号不是来自 Crypto++。 Crypto++ 使用 CryptoPP 命名空间。缺少的符号来自 CryptoV2 命名空间或 class。我猜那是另一个加密库。

您在链接器设置中添加目录和库是正确的。但是,您需要为 CryptoV2 库(除了 Crypto++ 库)执行此操作。

为了完整起见,似乎缺少以下内容:

std::string CryptoV2::encrypt(std::string);
std::string CryptoV2::hashPassword(std::string, std::string);

添加 #include "dll.h",如自述文件中所述:

To use the Crypto++ DLL in your application, #include "dll.h" before including any other Crypto++ header files, and place the DLL in the same directory as your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") so you don't have to explicitly list the import library in your project settings.

https://github.com/weidai11/cryptopp/blob/master/Readme.txt#L136