LNK2019 when including asio headers, solution generated with cmake

前端 未结 4 458
失恋的感觉
失恋的感觉 2021-02-04 12:26

I am trying to port a big project from gcc (Linux) to msvc (windows), using cmake and boost libraries.

The project compile and runs fine for gcc but on msvc it returns t

4条回答
  •  死守一世寂寞
    2021-02-04 12:44

    When running on windows you need (by default) to link to boost.system and boost.regex

    As it says here:

    Note With MSVC or Borland C++ you may want to add -DBOOST_DATE_TIME_NO_LIB and -DBOOST_REGEX_NO_LIB to your project settings to disable autolinking of the Boost.Date_Time and Boost.Regex libraries respectively. Alternatively, you may choose to build these libraries and link to them.

    If you don't want to link to other boost libraries then you can use the identical (non-boost) asio library from here.

    In terms of your CMakeLists.txt file, you want a line such as

    target_link_libraries (your_application ${Boost_LIBRARIES})
    

    to actually link the library.

    EDIT: also, have a look at How to link against boost.system with cmake, it could be that you have to specify the individual boost libraries specifically rather than ${Boost_LIBRARIES}

提交回复
热议问题