jeremy-rifkin / libassert

The most over-engineered C++ assertion library
MIT License
545 stars 36 forks source link

linker errors #97

Closed ilobilo closed 6 months ago

ilobilo commented 6 months ago

I'm getting linker errors when including the library from meson using:

import('cmake').subproject('libassert').dependency('libassert-lib')

c++20 g++ 13.2.0 ld.bfd 2.41

c++  -o netstack netstack.p/source_main.cpp.o -Wl,--as-needed -Wl,--no-undefined '-Wl,-rpath,$ORIGIN/subprojects/fmt-10.2.0' -Wl,-rpath-link,/home/ilobilo/Desktop/projects/netstack/build/subprojects/fmt-10.2.0 -Wl,--start-group subprojects/fmt-10.2.0/libfmt.so subprojects/libassert/liblibassert_lib.a /usr/lib/x86_64-linux-gnu/libz.so -Wl,--end-group
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): warning: relocation against `_ZTVN8cpptrace14lazy_exceptionE' in read-only section `.text._ZN8cpptrace13runtime_errorD0Ev[_ZN8cpptrace13runtime_errorD5Ev]'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `libassert::assertion_info::get_stacktrace() const':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/assert.cpp:544:(.text.unlikely+0x6f1): undefined reference to `cpptrace::raw_trace::resolve() const'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `libassert::assertion_info::get_raw_trace() const':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/assert.cpp:536:(.text.unlikely+0xb2a): undefined reference to `cpptrace::detail::get_raw_trace_and_absorb(unsigned long)'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `cpptrace::exception_with_message::exception_with_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&&, cpptrace::raw_trace&&)':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:340:(.text.unlikely+0xb70): undefined reference to `vtable for cpptrace::exception_with_message'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `libassert::detail::print_stacktrace[abi:cxx11](cpptrace::stacktrace const&, int, libassert::color_scheme const&, libassert::detail::path_handler*)':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/assert.cpp:81:(.text.unlikely+0xfea): undefined reference to `cpptrace::stacktrace::empty() const'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `libassert::stacktrace[abi:cxx11](int, libassert::color_scheme const&, unsigned long)':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/assert.cpp:637:(.text.unlikely+0x1fbc): undefined reference to `cpptrace::generate_trace(unsigned long)'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `cpptrace::exception_with_message::~exception_with_message()':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:333:(.text._ZN8cpptrace13runtime_errorD2Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x7): undefined reference to `vtable for cpptrace::exception_with_message'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `cpptrace::lazy_exception::~lazy_exception()':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:318:(.text._ZN8cpptrace13runtime_errorD2Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x2f): undefined reference to `vtable for cpptrace::lazy_exception'
/usr/bin/ld: /home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:318:(.text._ZN8cpptrace13runtime_errorD2Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x55): undefined reference to `cpptrace::detail::lazy_trace_holder::~lazy_trace_holder()'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `cpptrace::exception_with_message::~exception_with_message()':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:333:(.text._ZN8cpptrace13runtime_errorD0Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x7): undefined reference to `vtable for cpptrace::exception_with_message'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o): in function `cpptrace::lazy_exception::~lazy_exception()':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:318:(.text._ZN8cpptrace13runtime_errorD0Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x2f): undefined reference to `vtable for cpptrace::lazy_exception'
/usr/bin/ld: /home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:318:(.text._ZN8cpptrace13runtime_errorD0Ev[_ZN8cpptrace13runtime_errorD5Ev]+0x55): undefined reference to `cpptrace::detail::lazy_trace_holder::~lazy_trace_holder()'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o):(.data.rel.ro._ZTIN8cpptrace13runtime_errorE[_ZTIN8cpptrace13runtime_errorE]+0x10): undefined reference to `typeinfo for cpptrace::exception_with_message'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o):(.data.rel.ro._ZTVN8cpptrace13runtime_errorE[_ZTVN8cpptrace13runtime_errorE]+0x20): undefined reference to `cpptrace::lazy_exception::what() const'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o):(.data.rel.ro._ZTVN8cpptrace13runtime_errorE[_ZTVN8cpptrace13runtime_errorE]+0x28): undefined reference to `cpptrace::exception_with_message::message() const'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_assert.cpp.o):(.data.rel.ro._ZTVN8cpptrace13runtime_errorE[_ZTVN8cpptrace13runtime_errorE]+0x30): undefined reference to `cpptrace::lazy_exception::trace() const'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_utils.cpp.o): in function `libassert::detail::primitive_panic_impl(char const*, libassert::source_location, char const*)':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/utils.cpp:65:(.text.unlikely+0xe1e): undefined reference to `cpptrace::detail::get_raw_trace_and_absorb(unsigned long)'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_utils.cpp.o): in function `cpptrace::exception_with_message::exception_with_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, cpptrace::raw_trace&&)':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:340:(.text.unlikely+0xe51): undefined reference to `vtable for cpptrace::exception_with_message'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_utils.cpp.o): in function `libassert::detail::primitive_assert_impl(bool, bool, char const*, char const*, libassert::source_location, char const*)':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/src/utils.cpp:48:(.text.unlikely+0x1148): undefined reference to `cpptrace::detail::get_raw_trace_and_absorb(unsigned long)'
/usr/bin/ld: subprojects/libassert/liblibassert_lib.a(src_utils.cpp.o): in function `cpptrace::exception_with_message::exception_with_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, cpptrace::raw_trace&&)':
/home/ilobilo/Desktop/projects/netstack/build/subprojects/libassert/__CMake_build/_deps/cpptrace-src/include/cpptrace/cpptrace.hpp:340:(.text.unlikely+0x118a): undefined reference to `vtable for cpptrace::exception_with_message'
/usr/bin/ld: netstack.p/source_main.cpp.o: in function `void libassert::detail::process_assert_fail<tst&, tst&, libassert::detail::ops::eq, char const (&) [4], tst&, tst&, libassert::detail::pretty_function_name_wrapper>(libassert::detail::expression_decomposer<tst&, tst&, libassert::detail::ops::eq>&, libassert::detail::assert_static_parameters const*, char const (&) [4], tst&, tst&, libassert::detail::pretty_function_name_wrapper&&)':
/home/ilobilo/Desktop/projects/netstack/build/../subprojects/libassert/include/libassert/assert.hpp:1344:(.text._ZN9libassert6detail19process_assert_failIR3tstS3_NS0_3ops2eqEJRA4_KcS3_S3_NS0_28pretty_function_name_wrapperEEEEvRNS0_21expression_decomposerIT_T0_T1_EEPKNS0_24assert_static_parametersEDpOT2_[_ZN9libassert6detail19process_assert_failIR3tstS3_NS0_3ops2eqEJRA4_KcS3_S3_NS0_28pretty_function_name_wrapperEEEEvRNS0_21expression_decomposerIT_T0_T1_EEPKNS0_24assert_static_parametersEDpOT2_]+0xd7): undefined reference to `cpptrace::generate_raw_trace(unsigned long)'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
ilobilo commented 6 months ago

I needed to include all of these in dependencies:

libassert = import('cmake').subproject('libassert')

libassert.dependency('libzstd_static'),
libassert.dependency('libassert-lib'),
libassert.dependency('cpptrace-lib'),
libassert.dependency('dwarf')
jeremy-rifkin commented 6 months ago

Glad you got it working!