Using cmake I am not able to use boost::log
I still get this error undefined reference to:
boost::log::v2_mt_posix::trivial::logger::get()
I am using boost 1.71. I have this working like:
- g++ ../log_example.cpp -DBOOST_LOG_DYN_LINK -lpthread -lboost_log -o log_example
linker error while linking boost log (undefined references to boost::log::v2_mt_posix::sinks)
linking boost log using cmake error
However, With cmake I have try several different options mention before. Not a single one has works for cmake.
The cmake is as follows
cmake_minimum_required(VERSION 3.10)
project(log_example)
set(CMAKE_CXX_STANDARD 17)
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(CMAKE_CXX_COMPILER "g++")
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
find_package(Boost 1.70.0 COMPONENTS thread log REQUIRED log_setup)
include_directories(${BOOST_INCLUDE_DIRS})
add_executable(log_example log_example.cpp)
target_link_libraries(log_example pthread ${Boost_LIBRARIES} ${Boost_LOG_LIBRARY} )
set(CMAKE_CXX_FLAGS "-g -Wall -DBOOST_LOG_DYN_LINK")