jwt-cpp icon indicating copy to clipboard operation
jwt-cpp copied to clipboard

Compilation isssue in jwt.h from picojson include directories

Open sureshganapathyhacker opened this issue 4 years ago • 3 comments

jwt.h includes "picojson/picojson.h"...But the picojson directory is one level above where jwt.h file exists....So the inclusion should be as follows:

"../picojson/picojson.h" .... Otherwise there will be an compilation error. If a developer wants to download this lib and uses the header files as it is available in GitHub, I think you must change jwt.h as I mentioned.

Kindly let me know if I am wrong..

sureshganapathyhacker avatar Jan 18 '22 18:01 sureshganapathyhacker

While this was how it worked originally, jwt-cpp has come a long way since then (supporting multiple ssl and json libraries in multiple versions). The supposed way to do this is to configure your include paths in a way that makes picojson visible at that path. It doesn't need to be the version that ships with this repo, you can also use a already present one or system installed one.

The fact that "..." is used for including picojson instead of <...> is a relict of the time when picojson was the only supported library and should probably be changed. I am not at a PC, but I'll do so tomorrow.

As for the include failure. Make sure to configure the include path correctly, or use a package manager or cmakes fetchcontent to include and link the library. Copy pasting the file is a bad idea cause it prevents you from easily getting updates which, given jwt-cpp is usually used in a security sensitive context, is especially problematic. (We never had a security incident and take care when working on crypto code, but you can never be sure).

Thalhammer avatar Jan 18 '22 23:01 Thalhammer

The header includes are designed to be used with CMake. If you just download or clone the source, then yes they would be incorrect.

If you are using another build tool perhaps adding support here might be an option?

Sadly its it's difficult to support everything but we are open to ideas!

prince-chrismc avatar Jan 19 '22 01:01 prince-chrismc

Even jumping way back, it looks like we had the same issue

https://github.com/Thalhammer/jwt-cpp/tree/72553b24e42b80ab2b5d36608df988a73e8db18a

prince-chrismc avatar Jan 19 '22 01:01 prince-chrismc

Since https://github.com/Thalhammer/jwt-cpp/issues/213 has more information and possible solution I am closing this as a duplicate

prince-chrismc avatar Sep 17 '22 23:09 prince-chrismc