3

When using CMake, I get the following error when calling find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED):

-- Boost include dirs: C:/dev/boost/include/boost-1_72
-- Boost libraries:
Boost library
-- Found Boost 1.72.0 at C:/dev/boost/lib/cmake/Boost-1.72.0
--   Requested configuration: QUIET REQUIRED COMPONENTS program_options;thread;system
-- BoostConfig: find_package(boost_headers 1.72.0 EXACT CONFIG REQUIRED QUIET HINTS C:/dev/boost/lib/cmake)
-- BoostConfig: find_package(boost_program_options 1.72.0 EXACT CONFIG REQUIRED QUIET HINTS C:/dev/boost/lib/cmake)
-- Found boost_program_options 1.72.0 at C:/dev/boost/lib/cmake/boost_program_options-1.72.0
-- Boost toolset is vc142 (MSVC 19.25.28612.0)
-- Scanning C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant*.cmake
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-gd-x32-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-gd-x32-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-gd-x64-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-gd-x64-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-x32-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-x32-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-x64-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-x64-1_72.lib
CMake Error at C:/dev/boost/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package):
  Found package configuration file:

    C:/dev/boost/lib/cmake/boost_program_options-1.72.0/boost_program_options-config.cmake

  but it set boost_program_options_FOUND to FALSE so package
  "boost_program_options" is considered to be NOT FOUND.  Reason given by
  package:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_program_options-vc142-mt-gd-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-gd-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

  * libboost_program_options-vc142-mt-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

Call Stack (most recent call first):
  C:/dev/boost/lib/cmake/Boost-1.72.0/BoostConfig.cmake:185 (boost_find_component)
  C:/dev/cmake-3.17.0-win64-x64/share/cmake-3.17/Modules/FindBoost.cmake:444 (find_package)
  CMakeLists.txt:79 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/sbreuer/Documents/Uni/Praktikum/SunFlower/Simulation/code/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/sbreuer/Documents/Uni/Praktikum/SunFlower/Simulation/code/build/CMakeFiles/CMakeError.log".

I do not understand the problem here. I added the environment variables for the include and the lib directory. I am using CMake 3.17.0 and Boost 1.72.0

Kevin
  • 16,549
  • 8
  • 60
  • 74
Siminho
  • 109
  • 1
  • 2
  • 6

1 Answers1

2

The important section of the error is here:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_program_options-vc142-mt-gd-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-gd-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

  * libboost_program_options-vc142-mt-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

It shows the libraries that were found, and gives the reason why they were rejected. All of the libraries here are static, as indicated by the lib prefix on their names. However, your CMake configuration indicates you do not want to use static libraries (Boost_USE_STATIC_LIBS=OFF). To fix the error, you have two options:

  1. Set Boost_USE_STATIC_LIBS to ON:

    set(Boost_USE_STATIC_LIBS ON)
    find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED)
    
  2. Build the shared Boost libraries, so not only the static libraries are available.

Kevin
  • 16,549
  • 8
  • 60
  • 74