c++windowsvisual-studio-2017linker-errorscrypto++

Crypto++ library link error using Visual Studio 2017


I'm trying to use the Crypto++ librairy in my project (windows application). Using it, include, compilation work fine, but impossible to deal with the link error

Here is some exemple of link errors, there is more, but don't think it's revelant to copy paste all of them

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

Basically, I add the "Win32\Output\Release" directory of crypto++ to my linker's additionnal library directories properties, and also the main folder to my C/C++'s General's property "Additional Include Directories"

I've tried a lot of thinks, like adding the library as a new project (same errors), adding all cpp files to my project and compiling with it (not compiling), adding only .cpp files I was using (not realistic, too much), linking all different folder of the cryptopp610 releases (cryptdll, cryptlib, dll_output, Output, same errors), and now, I don't really know what more I can try. I makre also a lots of search, trying all solution I saw (don't remember all of them), still the same problems. I also try to create a new project to add crypto++ without long compilation or mysterious problem, but I also get linker error.

Do anyone got any advice to help me ? Anyway, thank's a lot, and pardon my English

EDIT: Need to add that on the new blank project, I get 63 unresolved external symbol, so I think I forgot to do some basic stuff, but can't figure out which


Solution

  • 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)
    

    The missing symbols are not from Crypto++. Crypto++ uses the CryptoPP namespace. The missing symbols are from the CryptoV2 namespace or class. I'm guessing that's another crypto library.

    You were right in adding directories and a library to the linker settings. However, you need to do it for the CryptoV2 library (in addition to the Crypto++ library).

    For completeness, it looks like these are missing:

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