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

Boost JSON traits kind of buggy #339

Closed manishjha5410 closed 3 months ago

manishjha5410 commented 3 months ago

What happened?

Whenever i tried to use boost json traits it just produce some random error

How To Reproduce?

Comment 
// #ifndef JWT_DISABLE_PICOJSON
// #ifndef PICOJSON_USE_INT64
// #define PICOJSON_USE_INT64
// #endif
// #include "picojson/picojson.h"
// #endif

// #ifndef JWT_DISABLE_PICOJSON
// #include "traits/kazuho-picojson/defaults.h"
// #endif
Use
#include "traits/boost-json/defaults.h"

Version

0.7.0

What OS are you seeing the problem on?

Linux

What compiler are you seeing the problem on?

GCC

Relevant log output

usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `boost::json::object::object(boost::json::object const&)':
/home/manish/Music/Dolat-Hackathon/boost_1_84_0/boost/json/object.hpp:406: undefined reference to `boost::json::object::object(boost::json::object const&, boost::json::storage_ptr)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `boost::json::value::value(boost::json::value const&)':
/home/manish/Music/Dolat-Hackathon/boost_1_84_0/boost/json/value.hpp:223: undefined reference to `boost::json::value::value(boost::json::value const&, boost::json::storage_ptr)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `boost::json::value::value(boost::core::basic_string_view<char>, boost::json::storage_ptr)':
/home/manish/Music/Dolat-Hackathon/boost_1_84_0/boost/json/value.hpp:632: undefined reference to `boost::json::string::string(boost::core::basic_string_view<char>, boost::json::storage_ptr)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `boost::json::value::value(boost::json::object)':
/home/manish/Music/Dolat-Hackathon/boost_1_84_0/boost/json/value.hpp:923: undefined reference to `boost::json::object::object(boost::json::object&&)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::traits::boost_json::serialize[abi:cxx11](boost::json::value const&)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/traits/boost-json/traits.h:75: undefined reference to `boost::json::serialize[abi:cxx11](boost::json::value const&, boost::json::serialize_options const&)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::~builder()':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2634: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2634: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::basic_claim<jwt::traits::boost_json>::~basic_claim()':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2127: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::set_issuer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2722: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2722: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::set_type(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2697: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2697: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o:/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2772: more undefined references to `boost::json::value::~value()' follow
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::set_payload_claim(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, jwt::basic_claim<jwt::traits::boost_json>)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2678: undefined reference to `boost::json::object::operator[](boost::core::basic_string_view<char>)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2678: undefined reference to `boost::json::value::operator=(boost::json::value&&)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2678: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2678: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::set_payload_claim(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::json::value)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2668: undefined reference to `boost::json::object::operator[](boost::core::basic_string_view<char>)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2668: undefined reference to `boost::json::value::operator=(boost::json::value&&)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `jwt::builder<jwt::traits::boost_json>::set_header_claim(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::json::value)':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2647: undefined reference to `boost::json::object::operator[](boost::core::basic_string_view<char>)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2647: undefined reference to `boost::json::value::operator=(boost::json::value&&)'
/usr/bin/ld: CMakeFiles/app.out.dir/BACKEND/User/User.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > jwt::builder<jwt::traits::boost_json>::sign<jwt::algorithm::hs256, jwt::builder<jwt::traits::boost_json>::sign<jwt::algorithm::hs256>(jwt::algorithm::hs256 const&, std::error_code&) const::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}>(jwt::algorithm::hs256 const&, jwt::builder<jwt::traits::boost_json>::sign<jwt::algorithm::hs256>(jwt::algorithm::hs256 const&, std::error_code&) const::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}, std::error_code&) const':
/home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::object::count(boost::core::basic_string_view<char>) const'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::object::operator[](boost::core::basic_string_view<char>)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::value::operator=(boost::json::value&&)'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2829: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2829: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2830: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2830: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2837: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::value::~value()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2827: undefined reference to `boost::json::object::~object()'
/usr/bin/ld: /home/manish/Music/Dolat-Hackathon/jwt-cpp-0.7.0/include/jwt-cpp/jwt.h:2837: undefined reference to `boost::json::object::~object()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/app.out.dir/build.make:161: app.out] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/app.out.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Code of Conduct

manishjha5410 commented 3 months ago

Please tell me guys if someone know the answer

prince-chrismc commented 3 months ago

That's not a random error that's a linker problem. You should do a little more research before opening issues especially bug reports.

The issue is with your build scripts. Please make sure you are using the correct version of Boost.Json in standalone mode. The README and CI pipeline have the tested matrix of JSON libraries. Newer versions are likely to not work.

You can find the support CMake configuration here https://github.com/Thalhammer/jwt-cpp/blob/master/cmake/private-find-boost-json.cmake

prince-chrismc commented 3 months ago

Feel free to ask more detailed questions if you need more help.

manishjha5410 commented 3 months ago

Hi can you provide an in detail steps to use jwt-cpp without picojson and only using boost-json i think there is no documentation correct me if i am wrong

prince-chrismc commented 3 months ago

We dont provide any installation intructions.... This is a problem for the whole ecosystem, here are links to how it's done in our CI.

I normally suggest using a package manager but the boost project dropped the standalone more which this is using so you need to use an older version (1.78.0 is the last one) -- this is a whole can of worms because they did not support std::string

Hopefully this helps.