cannot find boost_process cmake find_package
Asked Answered
S

1

12

I'm trying to import boost libraries into my C++ project, and for some reason it cannot find Boost.Process, although it finds the others.

My CMakeLists.txt file:

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 full trace of the error (with debug setting):

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)

I know Boost.Process was only included in Boost 1.64 and up, but according to the output I'm using Boost 1.64, and Cmake 3.9. I looked in /usr/local/include/boost and process.hpp was there.

Thanks for any advice.

Salman answered 29/8, 2017 at 5:42 Comment(6)
No, in general Boost 1.65 is too new and not yet supported by CMake beside it's Git master. Use Boost 1.64 just to be sure. See also https://mcmap.net/q/144737/-cmake-finds-boost-but-the-imported-targets-not-available-for-boost-versionCrock
Thanks for the comment. I switched to version 1.6.4 and still got the same message - 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. It did, however remove the warnings I was getting before - I'll edit the post.Salman
I Boost process installed? Have you checked the according files are there? It might be a seprate package to install or might need an additional dependecy to get compiled.Crock
I checked usr/local/include/boost and both process and process.hpp were thereSalman
I am out of ideas. Have you cleared you build directory and started over?Crock
I did try it; unfortunately no success. I updated the post with my full stack trace. I couldn't find an example of anyone online using the boost_process library with cmake; all the examples assumed it was configured.Salman
S
10

So, after hours of banging my head against the wall, I realized I didn't need to import Boost.Process with find_package since it's a header-only library (argggg). I removed the "process" import in CMakeList.txt and ta-dah: it worked.

Salman answered 29/8, 2017 at 18:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.