DLDR 如何将cmake指向boost-python3库? cmake不会自动检测到它。
我正在尝试使用提供的cmake为Python 3.6构建caffe。
我的系统规格:
我在brew上安装了Boost,例如
brew install boost boost-python3
我可以使用find / -name libboost* 2>/dev/null
看到Boost库。它们出现在三个目录中
/usr/local/Cellar/boost/1.67.0_1/lib/
/usr/local/lib/
->符号链接到上方/usr/local/Cellar/boost-python/1.67.0/lib/
如果我运行cmake -DCMAKE_PREFIX_PATH=<anaconda_env_path> -D python_version=3
,则会在输出的顶部得到
-- Boost version: 1.67.0
-- Found the following Boost libraries:
-- system
-- thread
-- filesystem
-- chrono
-- date_time
-- atomic
但进一步,我也得到
CMake Warning at /Users/Mauceri/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1723 (message):
No header defined for python-py365; skipping header check
Call Stack (most recent call first):
cmake/Dependencies.cmake:157 (find_package)
CMakeLists.txt:49 (include)
-- Could NOT find Boost
CMake Warning at /Users/Mauceri/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1723 (message):
No header defined for python-py36; skipping header check
Call Stack (most recent call first):
cmake/Dependencies.cmake:164 (find_package)
CMakeLists.txt:49 (include)
-- Could NOT find Boost
CMake Warning at /Users/Mauceri/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1723 (message):
No header defined for python-py3; skipping header check
Call Stack (most recent call first):
cmake/Dependencies.cmake:164 (find_package)
CMakeLists.txt:49 (include)
-- Could NOT find Boost
-- Could NOT find Boost
-- Python interface is disabled or not all required dependencies found. Building without it...
类似于Cmake doesn't find Boost,我尝试添加
-DBOOST_ROOT=/usr/local/Cellar/boost/1.67.0_1/lib/ -DBoost_DEBUG=1
到cmake命令。在结果输出中,以下命令对boost_python-py365,boost_python-py36,boost_python-py3和boost_python重复三遍:
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1121 ] _boost_TEST_VERSIONS = 1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1123 ] Boost_USE_MULTITHREADED = TRUE
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1125 ] Boost_USE_STATIC_LIBS =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1127 ] Boost_USE_STATIC_RUNTIME =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1129 ] Boost_ADDITIONAL_VERSIONS =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1131 ] Boost_NO_SYSTEM_PATHS =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1199 ] Declared as CMake or Environmental Variables:
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1201 ] BOOST_ROOT = /usr/local/Cellar/boost/1.67.0_1/include/
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1203 ] BOOST_INCLUDEDIR =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1205 ] BOOST_LIBRARYDIR =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1207 ] _boost_TEST_VERSIONS = 1.67.0;1.67;1.66.0;1.66;1.65.1;1.65.0;1.65;1.64.0;1.64;1.63.0;1.63;1.62.0;1.62;1.61.0;1.61;1.60.0;1.60;1.59.0;1.59;1.58.0;1.58;1.57.0;1.57;1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1306 ] location of version.hpp: /usr/local/Cellar/boost/1.67.0_1/include/boost/version.hpp
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1330 ] version.hpp reveals boost 1.67.0
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1416 ] guessed _boost_COMPILER =
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1426 ] _boost_MULTITHREADED = -mt
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1502 ] _boost_RELEASE_ABI_TAG = -
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1504 ] _boost_DEBUG_ABI_TAG = -d
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1567 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/Cellar/boost/1.67.0_1/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH_boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/Cellar/boost/1.67.0_1/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1756 ] Searching for PYTHON_LIBRARY_RELEASE: boost_python-mt-1_67;boost_python-mt;boost_python
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:400 ] Boost_LIBRARY_DIR_RELEASE = /usr/local/Cellar/boost/1.67.0_1/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/Cellar/boost/1.67.0_1/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1809 ] Searching for PYTHON_LIBRARY_DEBUG: boost_python-mt-d-1_67;boost_python-mt-d;boost_python-mt;boost_python
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:400 ] Boost_LIBRARY_DIR_DEBUG = /usr/local/Cellar/boost/1.67.0_1/lib _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/local/Cellar/boost/1.67.0_1/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
[ /Users/me/anaconda/share/cmake-3.11/Modules/FindBoost.cmake:1883 ] Boost_FOUND = 1
Could NOT find Boost
Boost version: 1.67.0
Boost include path: /usr/local/Cellar/boost/1.67.0_1/include
Could not find the following Boost libraries:
boost_python
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.
因此,我认为缺少了boost-python路径。我也尝试添加-DBOOST_LIBRARYDIR
,但这似乎没有任何改变。
FindBoost documentation包含有关boost-python的评论
请注意,Boost Python组件需要Python版本后缀 (提升1.67及更高版本),例如python36或python27版本 分别针对Python 3.6和2.7构建。这也适用于 使用Python的其他组件,包括mpi_python和numpy。 早期的Boost版本可能使用特定于发行版的后缀,例如 2、3或2.7。这些也可以用作后缀,但请注意它们 不便携。
我注意到boost-python3库的后缀为37(libboost_python37.a),因此我也尝试将anaconda环境与python 3.7一起使用,但是仍然存在相同的错误。
如何获取cmake来查找boost-python3库?