gpt4 book ai didi

c++ - Cmake 找不到 boost 库

转载 作者:搜寻专家 更新时间:2023-10-31 02:20:56 29 4
gpt4 key购买 nike

我在 Mac OS X 上使用以下 CMake 文件,Boost v1.58.0 安装在/usr/local/lib/boost_1_58_0,每次运行 cmake 时都会打印“Could NOT find Boost”。我已经通读了所有有关如何使它正常工作的堆栈溢出帖子,但没有任何效果。有什么我想念的吗?

cmake_minimum_required (VERSION 3.1)
project (HelloWorld)

set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_C_FLAGS}")
file (GLOB SOURCE_FILES "source/*.cpp")

set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/lib/boost_1_58_0/boost)
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib/boost_1_58_0/stage/lib)

set (Boost_NO_BOOST_CMAKE ON)
set (BOOST_NO_SYSTEM_PATHS ON)
set (BOOST_ROOT /usr/local/lib/boost_1_58_0)
set (BOOST_INCLUDEDIR /usr/local/lib/boost_1_58_0/boost)
set (BOOST_LIBRARYDIR /usr/local/lib/boost_1_58_0/stage/lib)

set (Boost_USE_STATIC_LIBS OFF)
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_RUNTIME OFF)
find_package (Boost 1.58.0 COMPONENTS optional)

if (Boost_FOUND)
include_directories (${Boost_INCLUDE_DIRS})
target_link_libraries (helloworld ${Boost_LIBRARIES})
endif ()

include_directories ("source")
add_executable (helloworld ${SOURCE_FILES})

最佳答案

这是错误的,因为 optional 不是库,它只是 header ,因此将其更改为 find_package (Boost 1.58.0) 解决了问题。

关于c++ - Cmake 找不到 boost 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32038150/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com