我正在尝试从源代码构建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)
老实说,在这一点上,我会采纳任何我可以尝试的建议。如果我能提供我没有想到的任何其他有用的信息,请随时发表评论或留言。谢谢
发布于 2019-02-19 08:14:23
正如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文件中就不应该有硬编码的路径了。
发布于 2019-02-19 08:08:27
几个月前我也遇到过同样的问题。这解决了我的问题。
find_package(Boost 1.67.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
https://stackoverflow.com/questions/54757097
复制相似问题