【发布时间】:2016-11-30 17:03:35
【问题描述】:
使用以下CMake 代码:
cmake_minimum_required(VERSION 3.6)
project(TrustLineManager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(BOOST_ROOT D:/Tools/boost_1_62_0/)
set(Boost_INCLUDE_DIRS D:/Tools/boost_1_62_0/boost)
set(Boost_LIBRARY_DIRS D:/Tools/boost_1_62_0/libs)
set(BOOST_INCLUDEDIR C:/MinGW/include)
set(BOOST_LIBRARYDIR C:/MinGW/lib)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost
1.62.0
COMPONENTS system
filesystem
REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(TrustLineManager ${Boost_LIBRARIES})
我收到此错误:
Error:Unable to find the requested Boost libraries.
Boost version: 1.62.0
Boost include path: D:/Tools/boost_1_62_0
Could not find the following static Boost libraries:
boost_system boost_filesystem
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.
我应该怎么做才能解决它?
编辑:
我将我的CMake 代码修改为:
cmake_minimum_required(VERSION 3.6)
project(TrustLineManager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
set(BOOST_ROOT "D:/Tools/boost_1_62_0")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(TrustLineManager ${SOURCE_FILES})
target_link_libraries(TrustLineManager Boost::filesystem Boost::thread)
我现在有这个错误:
Error:Target "TrustLineManager" links to target "Boost::filesystem" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
这是Boost目录内容的截图:
【问题讨论】:
-
为什么不按照错误消息中的说明进行操作?你确定 boost 的东西安装在
C:\MinGW吗? -
@πάντα ῥεῖ 导致 boost 目录不包含 forlders include 和 lib
-
你有哪个 CMake 版本?如果它太旧,它的“FindBoost.cmake”将无法找到最新的 Boost 版本。我认为仅在 CMake 3.7(或者可能是 CMake 3.6.3)中引入了对 Boost 1.62 的支持。