Thalhammer / jwt-cpp

A header only library for creating and validating json web tokens in c++
https://thalhammer.github.io/jwt-cpp/
MIT License
828 stars 229 forks source link

Linker error for OpenSSL on Windows #350

Closed gggamemaster closed 1 month ago

gggamemaster commented 1 month ago

What's your question?

what verison openssl should i use?

Additional Context

i download jwt-cpp using vcpkg,and i get image and i compile the openssl 1.0.1,i get image header folder image lib folder image and i write a test function image my project setting: header folder: image lib dir: image and i have join the lib libeay32.lib and ssleay32.lib to project,when i complile code,meet error error LNK2019: 无法解析的外部符号 _BIO_new,loos like i do not link the lib。what should i do?

Thalhammer commented 1 month ago

jwt-cpp supports all versions of openssl between 1.0.x and 3.x, so your while your version is on the older end (you should really use a recent one in the name of security) I think it should work fine.

I don't speak whatever language that is, but LNK**** errors usually mean that something with your linker setup is wrong. You have added the openssl path, however you also need to make sure you add the relevant libraries to the linker.

gggamemaster commented 1 month ago

if i use the right version of openssl,the lib after i compile the source code ,will generate lib libssl.lib and libcrypto.lib insteal of libeay32.lib and ssleay32.lib,am i right?i have compile the openssl and i get libeay32.lib and ssleay32.lib, it look like i use the wrong version of openssl

prince-chrismc commented 1 month ago

It's seems you have misused vcpkg. You have installed openssl with vcpkg and a second older copy manually?

So it not surprising you see different versions at link or runtime.

I would highly recommend using CMake and VCPKG together to install dependencies so you'll don't have conflicts in your system

https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-cmd

You will need to add ports for jwt-cpp and openssl. Though you will need to make sure you pick the versions since you can not mix them (as you have discovered)

prince-chrismc commented 1 month ago

@gggamemaster if you've passed this issue please close it :)

gggamemaster commented 1 month ago

i have passed it after reinstall openssl