0
votes

I'm trying to compile a tool which a teacher of mine gave me. It uses the Boost libraries (which I have set up and set the environment variables) and Boost is found by Cmake.

However, Cmake tells me it could not find the library named "boost_program_options". The output of cmake tells me that it is only looking for files with names "libboost_program_options-vc110-mt-1_61". In my Boost directory I'm only able to find files named "libboost_program_options-vc140-mt-1_61" which are all contained in D:\local\boost_1_61_0\lib64-msvc-14.0 (which I set BOOST_LIBRARYDIR to). BOOST_ROOT ist set to D:\local\boost_1_61_0 and BOOST_INCLUDEDIR is set to D:\local\boost_1_61_0\boost. So, why is Cmake looking for the wrong files?

The Cmake file I was given is

project(generator)
cmake_minimum_required(VERSION 2.8)
set(Boost_USE_STATIC_LIBS   ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_MIN_VERSION "1.55.0")
find_package(Boost COMPONENTS program_options REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
set(CMAKE_CXX_FLAGS "-lboost_program_options")

if(UNIX)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()
1

1 Answers

1
votes

In short:

Project for Visual Studio 11 should use Boost libraries with suffix -vc110. With libraries -vc140 Visual Studio 14 should be used instead. Version of MSVC is choosen by cmake-generator.

Explanations:

It is FindBoost.cmake script which search specific libraries. (You call this script via find_package(Boost)).

Boost uses libraries sufficies for differentiate libraries for different targets. Sufficies like -vc110 denotes compiler using which libraries has been compiled. -vc110 corresponds to Visual Studio 11, -vc140 - to Visual Studio 14.

In you case cmake-generator Visual Studio 11 is used (probably, it is default generator for your cmake installation). So Boost libraries should be compatible with its compiler. That is why only the libraries with -vc110 suffix are searched: other libraries cannot be linked with this compiler.