我正在尝试将 boost 库导入到我的 C++ 项目中,由于某种原因它找不到 Boost.Process,尽管它找到了其他库。
我的 CMakeLists.txt 文件:
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
set (PROJECT_NAME "test-stuff" CXX)
project (${PROJECT_NAME})
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.64.0 REQUIRED system filesystem process)
if(Boost_FOUND)
include_directories (SYSTEM ${Boost_INCLUDE_DIR})
endif()
include_directories(include)
file(GLOB SOURCES "src/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})
错误的完整跟踪(带有调试设置):
The CXX compiler identification is AppleClang 8.1.0.8020042
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1039 ] _boost_TEST_VERSIONS = 1.64.0;1.64
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1041 ] Boost_USE_MULTITHREADED = ON
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1043 ] Boost_USE_STATIC_LIBS =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1045 ] Boost_USE_STATIC_RUNTIME =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1047 ] Boost_ADDITIONAL_VERSIONS =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1049 ] Boost_NO_SYSTEM_PATHS =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1117 ] Declared as CMake or Environmental Variables:
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1119 ] BOOST_ROOT =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1121 ] BOOST_INCLUDEDIR =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1123 ] BOOST_LIBRARYDIR =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1125 ] _boost_TEST_VERSIONS = 1.64.0;1.64
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1200 ] Include debugging info:
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1202 ] _boost_INCLUDE_SEARCH_DIRS = PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1204 ] _boost_PATH_SUFFIXES = boost-1_64_0;boost_1_64_0;boost/boost-1_64_0;boost/boost_1_64_0;boost-1_64;boost_1_64;boost/boost-1_64;boost/boost_1_64
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1224 ] location of version.hpp: /usr/local/include/boost/version.hpp
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1248 ] version.hpp reveals boost 1.64.0
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1334 ] guessed _boost_COMPILER =
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1344 ] _boost_MULTITHREADED = -mt
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1388 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1390 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1452 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/include/lib;/usr/local/include/../lib;/usr/local/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/include/lib;/usr/local/include/../lib;/usr/local/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1597 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-mt-1_64;boost_system-mt;boost_system
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1646 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-mt-d-1_64;boost_system-mt-d;boost_system-mt;boost_system
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1597 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-mt-1_64;boost_filesystem-mt;boost_filesystem
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1646 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-mt-d-1_64;boost_filesystem-mt-d;boost_filesystem-mt;boost_filesystem
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
CMake Warning at /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1566 (message):
No header defined for process; skipping header check
Call Stack (most recent call first):
CMakeLists.txt:19 (find_package)
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1597 ] Searching for PROCESS_LIBRARY_RELEASE: boost_process-mt-1_64;boost_process-mt;boost_process
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_RELEASE = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1646 ] Searching for PROCESS_LIBRARY_DEBUG: boost_process-mt-d-1_64;boost_process-mt-d;boost_process-mt;boost_process
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:371 ] Boost_LIBRARY_DIR_DEBUG = /usr/local/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
-- [ /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1719 ] Boost_FOUND = 1
CMake Error at /usr/local/Cellar/cmake/3.9.1/share/cmake/Modules/FindBoost.cmake:1879 (message):
Unable to find the requested Boost libraries.
Boost version: 1.64.0
Boost include path: /usr/local/include
Could not find the following Boost libraries:
boost_process
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:19 (find_package)
我知道 Boost.Process 仅包含在 Boost 1.64 及更高版本中,但根据输出我使用的是 Boost 1.64 和 Cmake 3.9。我查看了 /usr/local/include/boost 并且 process.hpp 在那里。
感谢您的任何建议。