I decided to try boost :: stacktrace and reproduced the simplest example from the boost documentation. I use qt-creator 4.8, Cmake 3.10, GCC 7.3, boost 1.69.0.
Code:
#include <boost/stacktrace.hpp> #include <iostream> void Foo() { std::cout << boost::stacktrace::stacktrace() << std::flush << std::endl; } int main() { Foo(); return 0; } Cmake script:
cmake_minimum_required(VERSION 3.10) project(fast_test_3) add_definitions(-DBUILD_TYPE_="${CMAKE_BUILD_TYPE}") add_definitions(-DPROJECT_NAME_="${PROJECT_NAME}") set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread ") # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Wall -pthread -g -DDREAL_DEBUG -DDREAL_TRACE -fno-inline") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -Wall -pthread -Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -pthread -O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -Wall -pthread -O2 -g") set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED OFF) find_package(Boost REQUIRED system) include_directories (SYSTEM ${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARIES}) add_executable(${PROJECT_NAME} "main.cpp") target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) At compile time, the compiler produces four errors:
/.../main.cpp.o:-1: In function `boost :: stacktrace :: detail :: to_string [abi: cxx11] (boost :: stacktrace :: frame const *, unsigned long) ':
/.../main.cpp:-1: error: undefined reference to `dladdr '
/.../main.cpp:-1: error: undefined reference to `dladdr '
: -1: error: collect2: error: ld returned 1 exit status
As far as I know, boost :: stacktrace is a hederonly library and I cannot understand what the problem is?
UPD:
During the discussion, the question arose whether this hederonly library? I provide a link to the place in the documentation where this moment is negotiated.
-ldl- VTT