flogram_dev
flogram_dev

Reputation: 42858

How to find Boost filesystem library compiled with VS 2017 with CMake?

I have compiled Boost from source with Visual Studio 2017, and I'm using CMake 3.9.3 to find it with the following command in my CMakeLists.txt:

find_package(Boost REQUIRED COMPONENTS filesystem)

I'm invoking CMake like this:

cmake -G "Visual Studio 15 2017" ..
    -DBOOST_ROOT="C:\Users\emlai\src\libs\boost_1_65_0"
    -DBOOST_LIBRARYDIR="C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0"

I get the following message:

CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1902 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.0

  Boost include path: C:/Users/emlai/src/libs/boost_1_65_0

  Could not find the following Boost libraries:

          boost_filesystem

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:31 (find_package)


CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  build/cmake-modules/FindSDL2.cmake:173 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:42 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/emlai/src/zenith/build/CMakeFiles/CMakeError.log".

The output of dir C:\Users\emlai\src\libs\boost_1_65_0\lib64-msvc-15.0 shows that the filesystem libraries are in place.

I have tried all of the answers here, but without success. The same happens with the prebuilt Boost libraries downloaded from here.

How can I solve this problem?

Upvotes: 1

Views: 998

Answers (1)

flogram_dev
flogram_dev

Reputation: 42858

I needed to pass -DBoost_COMPILER="-vc141" to CMake to make it work (-vc141 being the same string as in the Boost library filenames).

Upvotes: 1

Related Questions