【发布时间】:2017-11-28 13:41:17
【问题描述】:
我使用 Visual Studio 2017 编译了 Boost 1.65.1。
使用 cmake 编译某些 C++ 项目时,找不到 Boost 库:
cmake -G"Visual Studio 15 2017" -DBoost_COMPILER="-vc150" ..
CMake Error at cmake-3.9/Modules/FindBoost.cmake:1900 (message):
Unable to find the requested Boost libraries.
Boost version: 1.65.1
Boost include path: C:/Boost/include/boost-1_65_1
Could not find the following Boost libraries:
boost_thread
boost_system
boost_regex
boost_timer
boost_filesystem
boost_serialization
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:18 (find_package)
图书馆在那里:
dir c:\Boost\lib
Volume in drive C has no label.
Directory of c:\Boost\lib
28/11/2017 12:47 <DIR> .
28/11/2017 12:47 <DIR> ..
...
28/11/2017 12:12 937.796 libboost_filesystem-vc150-mt-1_65_1.lib
28/11/2017 12:40 6.792.370 libboost_filesystem-vc150-mt-gd-1_65_1.lib
28/11/2017 12:20 996.592 libboost_filesystem-vc150-mt-s-1_65_1.lib
28/11/2017 12:17 5.951.092 libboost_filesystem-vc150-mt-sgd-1_65_1.lib
28/11/2017 12:28 996.456 libboost_filesystem-vc150-s-1_65_1.lib
28/11/2017 12:25 5.950.956 libboost_filesystem-vc150-sgd-1_65_1.lib
...
28/11/2017 12:13 13.418.950 libboost_regex-vc150-mt-1_65_1.lib
28/11/2017 12:40 43.663.182 libboost_regex-vc150-mt-gd-1_65_1.lib
28/11/2017 12:21 13.487.852 libboost_regex-vc150-mt-s-1_65_1.lib
28/11/2017 12:17 42.108.148 libboost_regex-vc150-mt-sgd-1_65_1.lib
28/11/2017 12:28 13.487.546 libboost_regex-vc150-s-1_65_1.lib
28/11/2017 12:25 42.107.842 libboost_regex-vc150-sgd-1_65_1.lib
28/11/2017 12:16 9.426.284 libboost_serialization-vc150-mt-1_65_1.lib
28/11/2017 12:43 33.389.696 libboost_serialization-vc150-mt-gd-1_65_1.lib
28/11/2017 12:24 10.690.636 libboost_serialization-vc150-mt-s-1_65_1.lib
28/11/2017 12:20 34.091.376 libboost_serialization-vc150-mt-sgd-1_65_1.lib
28/11/2017 12:31 10.690.106 libboost_serialization-vc150-s-1_65_1.lib
28/11/2017 12:27 34.090.846 libboost_serialization-vc150-sgd-1_65_1.lib
...
200 File(s) 2.184.720.662 bytes
2 Dir(s) 48.071.262.208 bytes free
如何在此配置中使用 Boost?
编辑:
我发现存在命名问题。来自 FindBoost.cmake:
# Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
# libraries ('mt' tag). Default is ON.
# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
# libraries. Default is OFF.
# Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
# libraries linked statically to the C++ runtime
# ('s' tag). Default is platform dependent.
# Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
# libraries linked to the MS debug C++ runtime
# ('g' tag). Default is ON.
# Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
# debug Python build ('y' tag). Default is OFF.
# Boost_USE_STLPORT - Set to ON to use libraries compiled with
# STLPort ('p' tag). Default is OFF.
# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
# - Set to ON to use libraries compiled with
# STLPort deprecated "native iostreams"
# ('n' tag). Default is OFF.
# Boost_COMPILER - Set to the compiler-specific library suffix
# (e.g. "-gcc43"). Default is auto-computed
# for the C++ compiler in use. A list may be
# used if multiple compatible suffixes should
# be tested for, in decreasing order of
# preference.
# Boost_THREADAPI - Suffix for "thread" component library name,
# such as "pthread" or "win32". Names with
# and without this suffix will both be tried.
# Boost_NAMESPACE - Alternate namespace used to build boost with
# e.g. if set to "myboost", will search for
# myboost_thread instead of boost_thread.
没有提到“gd”或“sgd”标签,但我的库是这样命名的。 我还尝试禁用所有可以使用这些标签的选项,但仍然失败:
cmake -G"Visual Studio 15 2017" -DBoost_COMPILER="-vc150" -DBOOST_LIBRARYDIR=/c/Boost/lib -DBoost_USE_STATIC_RUNTIME=OFF -DBoost_USE_DEBUG_RUNTIME=OFF ..
CMake Error at cmake-3.9/Modules/FindBoost.cmake:1900 (message):
Unable to find the requested Boost libraries.
Boost version: 1.65.1
Boost include path: C:/Boost/include/boost-1_65_1
Could not find the following Boost libraries:
boost_thread
boost_system
boost_regex
boost_timer
boost_filesystem
boost_serialization
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:18 (find_package)
【问题讨论】:
-
捆绑的 cmake 可以在这里从 boost 中找到预构建的 windows 二进制文件:dl.bintray.com/boostorg/release/1.65.1/binaries。主要区别在于库是按架构和编译器版本组织的,因此路径如下:C:\local\boost_1_65_1\lib32-msvc-14.1 和 C:\local\boost_1_65_1\lib64-msvc-14.1。也许它只是在那些文件夹中寻找库?
标签: boost cmake visual-studio-2017