简体   繁体   English

CMake搜索错误的文件?

[英]Cmake searching for wrong files?

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. 它使用Boost库(我已经设置并设置了环境变量),Boost由Cmake找到。

However, Cmake tells me it could not find the library named "boost_program_options". 但是,Cmake告诉我找不到名为“ 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". cmake的输出告诉我,它仅在查找名称为“ 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目录中,我只能找到名为“ libboost_program_options- vc140 -mt-1_61”的文件,这些文件都包含在D:\\ local \\ boost_1_61_0 \\ lib64-msvc-14.0中(我将BOOST_LIBRARYDIR设置为该文件)。 BOOST_ROOT ist set to D:\\local\\boost_1_61_0 and BOOST_INCLUDEDIR is set to D:\\local\\boost_1_61_0\\boost. BOOST_ROOT ist设置为D:\\ local \\ boost_1_61_0,而BOOST_INCLUDEDIR设置为D:\\ local \\ boost_1_61_0 \\ boost。 So, why is Cmake looking for the wrong files? 那么,Cmake为什么要寻找错误的文件?

The Cmake file I was given is 我得到的Cmake文件是

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()

In short: 简而言之:

Project for Visual Studio 11 should use Boost libraries with suffix -vc110 . Visual Studio 11的项目应使用带有后缀-vc110 Boost库。 With libraries -vc140 Visual Studio 14 should be used instead. 对于库-vc140-vc140 Visual Studio 14 Version of MSVC is choosen by cmake-generator . MSVC的版本由cmake-generator选择。

Explanations: 说明:

It is FindBoost.cmake script which search specific libraries. 搜索特定库的是FindBoost.cmake脚本。 (You call this script via find_package(Boost) ). (您可以通过find_package(Boost)调用此脚本)。

Boost uses libraries sufficies for differentiate libraries for different targets. Boost使用库足够来区分不同目标的库。 Sufficies like -vc110 denotes compiler using which libraries has been compiled. -vc110类的-vc110表示使用哪个库进行编译的编译器。 -vc110 corresponds to Visual Studio 11 , -vc140 - to Visual Studio 14 . -vc110对应Visual Studio 11-vc140 -到Visual Studio 14

In you case cmake-generator Visual Studio 11 is used (probably, it is default generator for your cmake installation). 如果使用cmake生成器,则使用Visual Studio 11 (可能是cmake安装的默认生成器)。 So Boost libraries should be compatible with its compiler. 因此Boost库应该与其编译器兼容。 That is why only the libraries with -vc110 suffix are searched: other libraries cannot be linked with this compiler. 这就是为什么只搜索带-vc110后缀的库的原因:其他库无法与此编译器链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM