Thalhammer / jwt-cpp

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

Compilation error: no matching function for call to ‘decode(std::string&)’ #328

Closed AvengerIl closed 7 months ago

AvengerIl commented 10 months ago

What's your question?

Following the example for print-claims.cpp

Additional Context

instaled with conan

[requires]
jwt-cpp/0.7.0
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
cmake . -DCMAKE_BUILD_TYPE="Release"
cmake --build .

produces:

/home/ks/source/conan/print-claims.cpp: In function ‘int main()’:
/home/ks/source/conan/print-claims.cpp:16:34: error: no matching function for call to ‘decode(std::string&)’
   16 |  auto decoded = jwt::decode(token);
      |                                  ^
In file included from /home/ks/source/conan/print-claims.cpp:6:
/home/ks/.conan2/p/jwt-ccf30d8200744c/p/include/jwt-cpp/jwt.h:3627:27: note: candidate: ‘template<class json_traits, class Decode> jwt::decoded_jwt<json_traits> jwt::decode(const typename json_trait
s::string_type&, Decode)’
 3627 |  decoded_jwt<json_traits> decode(const typename json_traits::string_type& token, Decode decode) {
      |                           ^~~~~~
/home/ks/.conan2/p/jwt-ccf30d8200744c/p/include/jwt-cpp/jwt.h:3627:27: note:   template argument deduction/substitution failed:
/home/ks/source/conan/print-claims.cpp:16:34: note:   candidate expects 2 arguments, 1 provided
   16 |  auto decoded = jwt::decode(token);
      |                                  ^
In file included from /home/ks/source/conan/print-claims.cpp:6:
/home/ks/.conan2/p/jwt-ccf30d8200744c/p/include/jwt-cpp/jwt.h:3639:27: note: candidate: ‘template<class json_traits> jwt::decoded_jwt<json_traits> jwt::decode(const typename json_traits::string_type
&)’
 3639 |  decoded_jwt<json_traits> decode(const typename json_traits::string_type& token) {
      |                           ^~~~~~
/home/ks/.conan2/p/jwt-ccf30d8200744c/p/include/jwt-cpp/jwt.h:3639:27: note:   template argument deduction/substitution failed:
/home/ks/source/conan/print-claims.cpp:16:34: note:   couldn’t deduce template parameter ‘json_traits’
   16 |  auto decoded = jwt::decode(token);
      |          
prince-chrismc commented 10 months ago

https://conan.io/center/recipes/jwt-cpp does not depend on a JSON library so you will need to explicitly add one. You can raise an issue in ConanCenterIndex to have options added for the different JSON options that are currently supported :)

327 should have some good tips for including the JSON library of your choice.

prince-chrismc commented 7 months ago

Going to mark this as resolved, feel free to open a new issue if you have other questions