我正在尝试从源代码构建PCL,但是CMake无法找到某些库。但是,当我检查那里的图书馆。我知道这已经被问了很多,但是我只是从CMake开始,我已经在互联网上搜索了好几天,却找不到可行的解决方案。我觉得我缺少任何帮助将不胜感激的东西
所以我按照别人的建议在我的CMakeLists.txt中写了这个
cmake_minimum_required(VERSION 3.13)
set(Boost_ADDITIONAL_VERSIONS "1.67.0")
set(BOOST_ROOT "C:/local/boost_1_67_0/boost")
set(BOOST_INCLUDEDIR "C:/local/boost_1_67_0/")
set(BOOST_LIBRARYDIR "C:/local/boost_1_67_0/lib64-msvc-14.0")
set (Boost_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.67.0)
但是我仍然收到相同的错误:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: C:/local/boost_1_67_0
Could not find the following static Boost libraries:
boost_filesystem
boost_thread
boost_date_time
boost_iostreams
boost_system
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):
cmake/pcl_find_boost.cmake:36 (find_package)
CMakeLists.txt:428 (include)
老实说,我会就目前可以尝试的事情提出建议。如果我可以提供我没有想到的任何其他有用信息,请随时发表评论或留言。 谢谢
答案 0 :(得分:0)
几个月前,我遇到了同样的问题。这解决了我的问题。
find_package(Boost 1.67.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
答案 1 :(得分:0)
像timko.mate建议的那样,find_package
带有组件是正确的方法。
但是,您应该考虑使用基于目标的API:
target_link_libraries(your_exe PUBLIC Boost::system Boost::filesystem)
此外,要使CMake找到Boost,您应该调整前缀路径。通常是在项目中调用cmake时完成的:
cmake -DMAKE_PREFIX_PATH=c:/local/ ..
那样,您的cmake文件中不应包含任何硬编码路径。