2

I have a project which uses boost 1.64.0 since I need boost process. Its CMakeList processed and the code compiled using Qt/Clion but when I use the same code with Visual Studio 2017 I got following error (bellow is output of boost 1.63.0 but I tried 1.64.0 at first time).

1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:987 ] _boost_TEST_VERSIONS = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:989 ] Boost_USE_MULTITHREADED = ON
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:991 ] Boost_USE_STATIC_LIBS = ON
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:993 ] Boost_USE_STATIC_RUNTIME = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:995 ] Boost_ADDITIONAL_VERSIONS = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:997 ] Boost_NO_SYSTEM_PATHS = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1065 ] Declared as CMake or Environmental Variables:
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1067 ]   BOOST_ROOT = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1069 ]   BOOST_INCLUDEDIR = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1071 ]   BOOST_LIBRARYDIR = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1073 ] _boost_TEST_VERSIONS = 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1166 ] location of version.hpp: D:/Program Files/boost_1_63_0/boost/version.hpp
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1190 ] version.hpp reveals boost 1.63.0
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1276 ] guessed _boost_COMPILER = -vc150
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1286 ] _boost_MULTITHREADED = -mt
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1330 ] _boost_RELEASE_ABI_TAG = -
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1332 ] _boost_DEBUG_ABI_TAG = -gd
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1388 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = D:/Program Files/boost_1_63_0/bin/x64;D:/Program Files/boost_1_63_0/lib;D:/Program Files/boost_1_63_0/stage/lib;D:/Program Files/boost_1_63_0/lib64-msvc-15.0;D:/Program Files/boost_1_63_0/lib;D:/Program Files/boost_1_63_0/../lib;D:/Program Files/boost_1_63_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG   = D:/Program Files/boost_1_63_0/bin/x64;D:/Program Files/boost_1_63_0/lib;D:/Program Files/boost_1_63_0/stage/lib;D:/Program Files/boost_1_63_0/lib64-msvc-15.0;D:/Program Files/boost_1_63_0/lib;D:/Program Files/boost_1_63_0/../lib;D:/Program Files/boost_1_63_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
1> CMake Warning at C:/.../cmake-3.7/Modules/FindBoost.cmake:746 (message):
1>   Imported targets not available for Boost version 106300
1> Call Stack (most recent call first):
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:850 (_Boost_COMPONENT_DEPENDENCIES)
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:1439 (_Boost_MISSING_DEPENDENCIES)
1>   projects/Visualizer/CMakeLists.txt:121 (find_package)
1> 
1> 
1> CMake Warning at C:/.../cmake-3.7/Modules/FindBoost.cmake:746 (message):
1>   Imported targets not available for Boost version 106300
1> Call Stack (most recent call first):
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:850 (_Boost_COMPONENT_DEPENDENCIES)
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:1439 (_Boost_MISSING_DEPENDENCIES)
1>   projects/Visualizer/CMakeLists.txt:121 (find_package)
1> 
1> 
1> CMake Warning at C:/.../cmake-3.7/Modules/FindBoost.cmake:746 (message):
1>   Imported targets not available for Boost version 106300
1> Call Stack (most recent call first):
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:850 (_Boost_COMPONENT_DEPENDENCIES)
1>   C:/.../cmake-3.7/Modules/FindBoost.cmake:1439 (_Boost_MISSING_DEPENDENCIES)
1>   projects/Visualizer/CMakeLists.txt:121 (find_package)
1> 
1> 
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1527 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc150-mt-1_63;libboost_system-vc150-mt;libboost_system-mt-1_63;libboost_system-mt;libboost_system;libboost_system-vc150-mt-s-1_63;libboost_system-vc150-mt-s;libboost_system-mt-s-1_63;libboost_system-mt-s
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1569 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc150-mt-gd-1_63;libboost_system-vc150-mt-gd;libboost_system-mt-gd-1_63;libboost_system-mt-gd;libboost_system-mt;libboost_system;libboost_system-vc150-mt-s-gd-1_63;libboost_system-vc150-mt-s-gd;libboost_system-mt-s-gd-1_63;libboost_system-mt-s-gd
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1527 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc150-mt-1_63;libboost_filesystem-vc150-mt;libboost_filesystem-mt-1_63;libboost_filesystem-mt;libboost_filesystem;libboost_filesystem-vc150-mt-s-1_63;libboost_filesystem-vc150-mt-s;libboost_filesystem-mt-s-1_63;libboost_filesystem-mt-s
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1569 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc150-mt-gd-1_63;libboost_filesystem-vc150-mt-gd;libboost_filesystem-mt-gd-1_63;libboost_filesystem-mt-gd;libboost_filesystem-mt;libboost_filesystem;libboost_filesystem-vc150-mt-s-gd-1_63;libboost_filesystem-vc150-mt-s-gd;libboost_filesystem-mt-s-gd-1_63;libboost_filesystem-mt-s-gd
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1527 ] Searching for THREAD_LIBRARY_RELEASE: libboost_thread-vc150-mt-1_63;libboost_thread-vc150-mt;libboost_thread-mt-1_63;libboost_thread-mt;libboost_thread;libboost_thread-vc150-mt-s-1_63;libboost_thread-vc150-mt-s;libboost_thread-mt-s-1_63;libboost_thread-mt-s
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1569 ] Searching for THREAD_LIBRARY_DEBUG: libboost_thread-vc150-mt-gd-1_63;libboost_thread-vc150-mt-gd;libboost_thread-mt-gd-1_63;libboost_thread-mt-gd;libboost_thread-mt;libboost_thread;libboost_thread-vc150-mt-s-gd-1_63;libboost_thread-vc150-mt-s-gd;libboost_thread-mt-s-gd-1_63;libboost_thread-mt-s-gd
1> -- [ C:/.../cmake-3.7/Modules/FindBoost.cmake:1639 ] Boost_FOUND = 1
1> CMake Error at C:/.../cmake-3.7/Modules/FindBoost.cmake:1795 (message):
1>   Unable to find the requested Boost libraries.
1> 
1>   Boost version: 1.63.0
1> 
1>   Boost include path: D:/Program Files/boost_1_63_0
1> 
1>   Could not find the following static Boost libraries:
1> 
1>           boost_system
1>           boost_filesystem
1>           boost_thread
1> 
1>   No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
1>   directory containing Boost libraries or BOOST_ROOT to the location of
1>   Boost.

As suggested here I downgrade boost to 1.63.0 but it got same error again.

Is there any suggestion about the problem(I am sure that I set the BOOST_ROOT, BOOST_INCLUDEDIR and BOOST_LIBRARYDIR appropriately)?

Can I upgrade VS2017-cmake to use cmake 3.8 (install cmake 3.8 separately and browse VS2017 to use it)?

VS2017(cmake 3.7) is compatible with which version of boost?

Bonje Fir
  • 787
  • 8
  • 25
  • 1
    See the source of [`FindBoost.cmake`](https://github.com/Kitware/CMake/blob/v3.7.0/Modules/FindBoost.cmake#L946). So, looking at that, we can see that CMake 3.7.0 is only aware of boost 1.62.0 as latest version, [as well as](https://github.com/Kitware/CMake/blob/v3.7.0/Modules/FindBoost.cmake#L429) not capable of detecting boost built using the compiler from MSVS 2017 (even though CMake itself supports it). – Dan Mašek Sep 04 '17 at 14:36
  • @DanMašek Thanks. Now I am curious that what this means "...Cmake not capable of detecting boost built using the compiler from MSVS 2017..."? CMake must check the existence of libs and dlls which simply can done with referring to boost paths. What it must do more? Finally this(your comment) means that there is no way to use boost in VS2017-cmake project? – Bonje Fir Sep 04 '17 at 14:48
  • I don't see a reason why you shouldn't be able to install an up to date version of CMake and use it (I don't have MSVS 2017, but I've been using CMake for years now -- honestly not sure what MS could have added other than complicating things). | Regarding your last question - the boost libraries on windows contain a token in their name signifying which compiler they were built with. In 3.7.0, the detection script is not aware of token `-vc141`, which corresponds to the latest MSVC. | Of course, it's just a script, so you can patch it to add the things missing, if necessary. – Dan Mašek Sep 04 '17 at 14:54
  • Also note that based on the release notes of Boost, only version 1.65.0 is fully tested with MSVC 14.1. Version 1.64.0 has the compiler listed only in the "additional test compilers", 1.63.0 not at all. – Dan Mašek Sep 04 '17 at 14:58
  • @DanMašek Thanks Dan, I am going to check 1.65.0. :) – Bonje Fir Sep 04 '17 at 15:02
  • 1
    On CMake 3.8.x did you try to add the followng to your CMakeLists.txt: `set(Boost_ADDITIONAL_VERSIONS "1.65" "1.65.0") ` this is the way to get around CMake not supporting a new version of boost. I don't think CMake 3.7 will work at all. – drescherjm Sep 04 '17 at 15:04
  • 1
    There might still be some issues and release 1.65.1 is imminent. There is a kind of race condition between boost releases and surprise compiler upgrades. – Bo Persson Sep 04 '17 at 15:17
  • @DanMašek and BoPersson. As BoPersson said there is issue with 1.65.0 (same error which is not unable to find boost) :(. There is two trivial solution wait for Microsoft update VS2017 with cmake 3.8 or boost release v1.65.1 but I do no what can do now to develop project. It is very awful which these two cannot integrate with each other! – Bonje Fir Sep 05 '17 at 13:14
  • Does CMake 3.8 still not find boost wth `Boost_ADDITIONAL_VERSIONS` set? I would have expected that to work. – drescherjm Sep 05 '17 at 15:54
  • I am testing boost 1.65.0 with CMake-3.8 right now. To build my entire work development tree (over 10 million lines of code). It should be finished in a few hours. – drescherjm Sep 05 '17 at 16:20
  • My test succeeded. CMake-3.8.0 does find boost-1.65.0 when you `set(Boost_ADDITIONAL_VERSIONS "1.65" "1.65.0")` before `find_package( Boost REQUIRED )` without the `Boost_ADDITIONAL_VERSIONS` it does not find boost. This is understandable because `boost-1.65.0` was released after `CMake-3.8.0`. – drescherjm Sep 05 '17 at 18:00
  • @drescherjm Do you test with MSVS2017? I tested it and got the error. could not find boost! – Bonje Fir Sep 06 '17 at 07:54
  • @drescherjm The problem here is VS2017 has Cmake 3.7 as embedded tool and it could not find boost. Cmake 3.8 is compatible with boost 1.64 (I tested before using Qt _Qt with Cmake 3.8 and msvc-14.1_) and 1.65 (you said above). i.e. VS2017 could not work with Cmake 3.8(has Cmake 3.7) and boost 1.6x or upper could not work with (Cmake 3.7 & msvc-14.1)! – Bonje Fir Sep 06 '17 at 07:56
  • @drescherjm **[** Qt + cl.exe(msvc-14.1) + _No debugger_ + boost 1.64 + cmake 3.8 **]** work fine (but I have not msvc14.1 debbuger). **[** MSVC2017 + cl.exe(msvc-14.1) + (MSVC17 embedded debugger) + boost 1.6x + cmake 3.7 **]** does not work fine because of incompatibality between cmake 3.7 & boost 1.6x & msvc-14.1 – Bonje Fir Sep 06 '17 at 08:04
  • @drescherjm Can we change VS2017 Cmake tool(externally I install Cmake 3.8 and browse VS2017 to use it as build tool)? or can we browse Qt to use MSVC2017 debugger as its debugger? (for the last question I could not find "cdb.exe" (version 2017)). – Bonje Fir Sep 06 '17 at 08:12
  • I tested with an older version of visual studio using cmake directly to generate a visual studio project. I don't have vs 2017 installed so I have not used the server integration mode. I assume if you have a CMakeLists.txt you can get CMake to generate a vs 2017 project directly. – drescherjm Sep 06 '17 at 12:18
  • `Visual Studio 15 2017` is listed as a generator in CMake-3.9. I don't have 3.8 here. I do have that at work however but no Visual Studio 2017 there.. – drescherjm Sep 06 '17 at 12:26
  • @drescherjm Thanks. I found what was wrong. Small change in the VS2017 CMake file made every thing true. – Bonje Fir Sep 06 '17 at 13:55
  • 1
    @DanMašek Thanks. Maybe `-v150` is an small bug in the `FindBoost.Cmake`. – Bonje Fir Sep 06 '17 at 13:59

1 Answers1

1

I used Visual studio to compile a Cmake-based project which uses boost 1.64.0. The problem was Visual studio's CMake(v3.7) which is unable to find the boost libs/dlls. As figure out Dan Masek CMake add a token -vc141 to boost libs/dlls when build it and FindBoost must know it(token is -vc140, -vc141 or etc) in order to find them.

In the CMake(v3.7) this token is -v150 for boost which it build with Visual Studio 2017. Changing that with -v141 made every thing true.

Summary: In order to find Visual Studio 2017 boost libs/dlls: Find file FindBoost.cmake and at line 431 change set(_boost_COMPILER "-vc150") to set(_boost_COMPILER "-vc141").

Bonje Fir
  • 787
  • 8
  • 25