Skip to content

Undefined reference error #416

@t1m-k

Description

@t1m-k

What's your question?

How to solve undefined reference error?

Additional Context

I guess that the error is connected somehow with OpenSSL. Here is context.
As I use debain-based kali linux, I have installed libssl-dev package. So now I have openssl binary at /usr/bin/openssl, all .h header files at /usr/include/opensll/, and such files as libssl.so or libcrypto.a are located at /usr/lib/x86_64-linux-gnu/.
openssl --version gives following output: OpenSSL 3.5.4 30 Sep 2025 (Library: OpenSSL 3.5.4 30 Sep 2025)

I build the library using command cmake -S . -B build -DOPENSSL_INCLUDE_DIR='/usr/include/openssl/' -DOPENSSL_CRYPTO_LIBRARY='/usr/lib/x86_64-linux-gnu/libssl.so' and there are no errors.
Then I use cmake --build build. And here is the output:

[  2%] Building CXX object example/CMakeFiles/print-claims.dir/print-claims.cpp.o
[  5%] Linking CXX executable print-claims
[  5%] Built target print-claims
[  8%] Building CXX object example/CMakeFiles/private-claims.dir/private-claims.cpp.o
[ 11%] Linking CXX executable private-claims
[ 11%] Built target private-claims
[ 14%] Building CXX object example/CMakeFiles/rsa-create.dir/rsa-create.cpp.o
[ 17%] Linking CXX executable rsa-create
/usr/bin/ld: CMakeFiles/rsa-create.dir/rsa-create.cpp.o: in function `jwt::helper::evp_pkey_handle::decrement_ref_count(evp_pkey_st*)':
/home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:496:(.text._ZN3jwt6helper15evp_pkey_handle19decrement_ref_countEP11evp_pkey_st[_ZN3jwt6helper15evp_pkey_handle19decrement_ref_countEP11evp_pkey_st]+0x1b): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: CMakeFiles/rsa-create.dir/rsa-create.cpp.o: in function `jwt::helper::make_mem_buf_bio()':
/home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:502:(.text._ZN3jwt6helper16make_mem_buf_bioEv[_ZN3jwt6helper16make_mem_buf_bioEv]+0xf): undefined reference to `BIO_free_all'
/usr/bin/ld: /home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:502:(.text._ZN3jwt6helper16make_mem_buf_bioEv[_ZN3jwt6helper16make_mem_buf_bioEv]+0x18): undefined reference to `BIO_s_mem'
/usr/bin/ld: /home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:502:(.text._ZN3jwt6helper16make_mem_buf_bioEv[_ZN3jwt6helper16make_mem_buf_bioEv]+0x20): undefined reference to `BIO_new'
/usr/bin/ld: CMakeFiles/rsa-create.dir/rsa-create.cpp.o: in function `jwt::helper::make_mem_buf_bio(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:512:(.text._ZN3jwt6helper16make_mem_buf_bioERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN3jwt6helper16make_mem_buf_bioERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x14): undefined reference to `BIO_free_all'
/usr/bin/ld: /home/kali/work/dev/jwt-cpp/include/jwt-cpp/jwt.h:512:(.text._ZN3jwt6helper16make_mem_buf_bioERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN3jwt6helper16make_mem_buf_bioERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x3c): undefined reference to `BIO_new_mem_buf'
...

So the error occurs when trying to use openssl functions (EVP_PKEY_free, etc). Also, I use the only one version of openssl, so #311 doesn't fit the problem (as I think).

I have no more ideas about this, so opened the issue asking for help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions