On 9/15/20 7:44 PM, Karmethia Thompson via Boost wrote:
Andrey thanks for your reply. I tried that as well without success. My cmake file is below:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions(-DBOOST_LOG_DYN_LINK=1)
## Common parameters. # Set common path variables. (YOURS MAY BE DIFFERENT) set(BOOST_ROOT "$ENV{BOOST_ROOT}")
set(ARMADILLO_HOME "$ENV{ARMADILLO_ROOT}") include_directories (${ARMADILLO_HOME}/include) link_directories (${ARMADILLO_HOME}/lib64) #SET(CMAKE_VERBOSE_MAKEFILE ON)
# Set the path to Boost #SET(Boost_USE_STATIC_LIBS ON) #SET(Boost_USE_MULTITHREADED ON) find_package (Boost COMPONENTS log log_setup system thread filesystem date_time REQUIRED) include_directories (${Boost_INCLUDE_DIRS}) link_directories (${Boost_LIBRARY_DIRS}) #link_libraries(${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/modules")
# Retrieve the list of source files. file (GLOB SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file (GLOB MODULE_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/*.cpp)
add_executable (main main.cpp ${SOURCE} ${MODULE_SOURCE} ) target_link_libraries(main boost_log) target_link_libraries (main ${Boost_LIBRARIES} -lpthread)
I'm not sure, but I think the above would generate incorrect order of libraries in the linker command line. You need to ensure that boost_log comes after boost_log_setup, and their dependencies come after still. So it should be: boost_log_setup, boost_log, boost_thread, boost_filesystem, boost_system, boost_date_time, pthread. You can see the linker command line if you add VERBOSE=1 environment variable before make. Also, you don't need to specify -l in target_link_libraries (i.e. you should specify pthread instead of -lpthread). Also, please don't top-post.