May this be useful to some people. I got a naughty error: undefined reference to the symbol "_ZN5boost6system15system_categoryEv" // usr / lib / x86_64-linux-gnu / libboost_system.so.1.58.0: error when adding characters: DSO is not on the command line and for some reason I was missing explicitly enable the "system" and "filesystem" libraries. So, I wrote these lines in CMakeLists.txt
These lines are written at the beginning before the creation of the project executable file, since at this stage we do not need to link the boost library to our project executable file.
set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_NO_SYSTEM_PATHS TRUE) if (Boost_NO_SYSTEM_PATHS) set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../3p/boost") set(BOOST_INCLUDE_DIRS "${BOOST_ROOT}/include") set(BOOST_LIBRARY_DIRS "${BOOST_ROOT}/lib") endif (Boost_NO_SYSTEM_PATHS) find_package(Boost COMPONENTS regex date_time system filesystem thread graph program_options) find_package(Boost REQUIRED regex date_time system filesystem thread graph program_options) find_package(Boost COMPONENTS program_options REQUIRED)
Now, at the end of the file, I wrote these lines, considering "KeyPointEvaluation" as the executable file of my project.
if(Boost_FOUND) include_directories(${BOOST_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) add_definitions(${Boost_DEFINITIONS}) include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(KeyPointEvaluation ${Boost_LIBRARIES}) target_link_libraries( KeyPointEvaluation ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY}) endif()
Spandan Jan 29 '18 at 10:06 2018-01-29 10:06
source share