Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to jwtpp::claims::claims() #46

Closed
NeleOb opened this issue Dec 28, 2022 · 1 comment
Closed

undefined reference to jwtpp::claims::claims() #46

NeleOb opened this issue Dec 28, 2022 · 1 comment

Comments

@NeleOb
Copy link

NeleOb commented Dec 28, 2022

Hi troian,
I have the following problem:
When inserting the following line into my code:

jwtpp::claims cl;

I get the following error code when building:

undefined reference to `jwtpp::claims::claims()`

The same with:

std::string key = "some";
std::string value = "test";
cl.set().any(key, value);
undefined reference to `jwtpp::claims::set::any(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

and

std::string encoded = jws::sign_bearer(cl, signer);
undefined reference to `jwtpp::jws::sign_bearer[abi:cxx11](jwtpp::claims&, std::shared_ptr<jwtpp::crypto>)'

and

jwtpp::sp_jws jws = jws::parse(encoded);
undefined reference to `jwtpp::jws::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

On the other hand the following lines work:

cl.set().nbf(value);
cl.set().exp(value);
jwtpp::sp_crypto signer = std::make_shared<jwtpp::hmac>("secret", jwtpp::alg_t::HS256);

I used the tests as a guide and examples.

Could you please help me?

CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.0)
project(project VERSION 0.1.0)

include(CTest)
enable_testing()

find_package(OpenSSL REQUIRED)

# C++ Library 
add_subdirectory(jsoncpp)
get_target_property(jsoncpp/include jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(jsoncpp/include)
add_library(jwtpp INTERFACE)
target_include_directories(jwtpp INTERFACE jwtpp/include)

add_executable(project main.cpp libraries_cpp_jwtpp_2.cpp)

target_link_libraries(project jwtpp jsoncpp_lib)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
@troian
Copy link
Owner

troian commented Jan 15, 2023

undefined reference usually means it cannot link the the source.

mind sharing entire project somehow?

@troian troian closed this as completed Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants