How to link against boost.system with cmake

后端 未结 2 1657
日久生厌
日久生厌 2020-12-13 01:55

I use a cmake generated makefile to compile a c++ file that depends on the boost filesystem library.

During the linking process I get the following error:

2条回答
  •  不知归路
    2020-12-13 02:35

    On linux CMake figures itself that boost_filesystem is linked against boost_system. Obviously you have to tell it explicitly on Mac:

    find_package(Boost COMPONENTS system filesystem REQUIRED)
    #...
    target_link_libraries(mytarget 
      ${Boost_FILESYSTEM_LIBRARY}
      ${Boost_SYSTEM_LIBRARY}
    )
    

提交回复
热议问题