首页 > 解决方案 > Cmake 找不到带有错误消息的库路径

问题描述

我尝试将库( PCL )添加到我的 cmake 中,但在尝试构建时会引发以下错误:

C/C++ debug|armeabi-v7a : CMake Error at C:\Users\xxx\ndktest\app\src\main\cpp\CMakeLists.txt:48 (find_package):
By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "PCL", but
CMake did not find one.

Could not find a package configuration file provided by "PCL" (requested
version 1.3) with any of the following names:

PCLConfig.cmake
pcl-config.cmake

Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR"
to a directory containing one of the above files.  If "PCL" provides a
separate development package or SDK, be sure it has been installed.

这是我的 cmake 的样子(我已经尝试设置 PLC_DIR 并且仍然有相同的错误消息):

cmake_minimum_required(VERSION 3.4.1)
add_library( native-lib SHARED native-lib.cpp )
find_library(log-lib log )
target_link_libraries(native-lib ${log-lib} )

set(PCL_DIR "C:\\Program Files\\PCL 1.6.0\\cmake\\PCLConfig.cmake")
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})

我正在运行windows 10,并试图包含PCL到一个Android项目中

有什么建议为什么它找不到 pcl 库?

编辑:我曾经vcpkg安装库PCL,我注意到我指向错误的 PCL 库。现在我指向安装的 PCL 库vcpkg,我的 CMAKE 现在看起来像这样:

cmake_minimum_required(VERSION 3.4.1)
add_library( native-lib SHARED native-lib.cpp )
find_library(log-lib log )
target_link_libraries(native-lib ${log-lib} )


set(PCL_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\packages\\pcl_x86-windows\\share\\pcl")
find_package(PCL 1.3 REQUIRED COMPONENTS)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})

当我运行它时,错误消息会发生变化(猜测它找到了 PCL,但无法找到 pcl 所需的库(Eigen)):

C:\Users\xxx\ndktest\app\src\main\cpp\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error at C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:56 (message):
  common is required but eigen was not found
Call Stack (most recent call first):
  C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:356 (pcl_report_not_found)
  C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:524 (find_external_library)
  CMakeLists.txt:10 (find_package)

我试过添加set(EIGEN_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\eigen3") or set(EIGEN_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\eigen3"),但它仍然会显示相同的错误消息common is required but eigen was not found。有任何想法吗?

EDIT2:将 PCL_DIR 设置为set(PCL_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\pcl")也具有相同的结果

标签: c++cmakeandroid-ndkpoint-cloud-libraryvcpkg

解决方案


推荐阅读