1

I am trying to create, validate, and get data from a jwt token using C++. The library I choose is jwt-cpp because I found it easy to use and it supports almost every algorithm.

For the setup, I followed this answer.

  • Configured the compiler: Added installed openssl include folder path Added installed openssl include folder path

Additionally, there is another path for using jwt-cpp library.

  • Configure the linker: Setting installed openssl lib folder to linker->general Setting installed openssl lib folder to linker->general Setting libcrypto and libssl lib to linker->input Setting libcrypto and libssl lib to linker->input

  • Copying libcrypto and libssl dll to executable folder Copying libcrypto and libssl dll to executable folder

After that, while following the basic tutorial in the jwt-cpp link, I can read all claims and header from the token.

But, when I try to execute token verification or creation (as code provided in the link), I get LNK2019

Error   LNK2019 unresolved external symbol _HMAC referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall jwt::algorithm::hmacsha::sign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::error_code &)const " (?sign@hmacsha@algorithm@jwt@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV45@AAVerror_code@5@@Z)

and

>Error  LNK2019 unresolved external symbol _HMAC referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall jwt::algorithm::hmacsha::sign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::error_code &)const " (?sign@hmacsha@algorithm@jwt@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV45@AAVerror_code@5@@Z)

I can guess that the issue can be in linker setup. I also found a lot of versions of libcrypto and libssl like libcrypto64MD, libcrypto64MDd libcrypto64MT, libcrypto64MTd, libssl64MD, libssl64MDd libssl64MT, libssl64MTd.

Can anybody tell me what can be the issue here?

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Ank Raw
  • 155
  • 10
  • 3
    The screenshots indicate that you made the changes in the Debug Win32 configuration, but then you show the 64-bit crypto/ssl DLLs. Make sure you edit the configuration(s) that you actually want to build, and you use the matching bitness for the LIBs and DLLs. – dxiv Nov 28 '20 at 05:00
  • 2
    Thanks @dxiv , this was the issue. I changed everything to x64 arch and everything is working fine now. – Ank Raw Nov 29 '20 at 04:49

0 Answers0