【问题标题】:Compile a PCL code example with QtCreator using CMakeLists file使用 CMakeLists 文件使用 QtCreator 编译 PCL 代码示例
【发布时间】:2012-11-29 19:28:31
【问题描述】:

我正在尝试使用 CMakeLists.txt 文件编译带有 QtCreatorPCL 示例。 FindPCL.cmake 文件(从这里获得:Last of the attached files)位于源文件的同一目录中。

我的 CMakeLists.txt 文件是:

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(pclcmake)
list(APPEND CMAKE_MODULE_PATH "C:/CMake2.8/bin")
set(PCL_ROOT "E:/LIBRERIAS/PCL1.5.1")
set(PCL_DIR "E:/LIBRERIAS/PCL1.5.1/cmake")
find_package(PCL 1.5.1 REQUIRED COMPONENTS common octree io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcl_cmake main.cpp)
target_link_libraries(pcl_cmake ${PCL_COMMON_LIBRARIES} ${PCL_OCTREE_LIBRARIES} ${PCL_IO_LIBRARIES})

我要编译的代码是这样的:

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

#include <iostream>

int main(int argc, char* argv[]) {
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file
  {
     std::cout << "Nope\n";
     return (-1);
  }
  std::cout << "Loaded " << cloud->width * cloud->height << " data points from test_pcd.pcd with the following fields: " << std::endl;
  for (size_t i = 0; i < cloud->points.size (); ++i)
     std::cout << "    " << cloud->points[i].x << " "    << cloud->points[i].y << " "    << cloud->points[i].z << std::endl;

  return (0);
}

我还在我的 CMakeLists.txt 中设置了 PCL_DIR 变量指向 PCL 安装目录,如底部的 PCL 教程 Using PCL in your own project 中所述。

最后,我得到的错误是:

CMake Error at CMakeLists.txt:6 (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.5.1) 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.

有什么想法吗? 提前致谢。

PS:在CMakeLists文件中,我将CMAKE_MODULE_PATH指向CMake二进制文件的目录。对吗?

PS2:我正在使用 MingW 编译器。

PS3:SO 是 Windows 7 64 位。

【问题讨论】:

  • 哇哦哦哦哦,忘了!!我会编辑帖子!谢谢!
  • 另外,我使用的编译器是 MingW。我已经将该信息添加到帖子中。
  • 你得到正确答案了吗?
  • @YeYeahPing 对不起?
  • 我也遇到过这个问题。

标签: windows-7 cmake qt-creator point-cloud-library


【解决方案1】:

您应该将CMAKE_MODULE_PATH 设置为包含FindPCL.cmake 的目录。如果此目录是模块的标准 CMake 目录 (share/cmake/Modules),则根本不需要它。

因此,将CMAKE_MODULE_PATH 设置为bin/ 目录是错误的。

【讨论】:

  • 您好,感谢您的回复。 FindPCl.cmake 在另一个目录(PCL1.5.1/cmake)中。所以我尝试了:list(APPEND CMAKE_MODULE_PATH "E:/LIBRERIAS/PCL1.5.1/cmake"),它失败并出现同样的错误。然后我尝试将list(APPEND ...) 行更改为set(CMAKE_MODULE_PATH "E:/LIBRERIAS/PCL1.5.1/cmake"),再次失败。此外,评论或取消评论 set(PCL_DIR...) 行无关紧要,它再次失败。 :(
  • find_package()调用之前尝试set(CMAKE_PREFIX_PATH E:/LIBRERIAS/PCL1.5.1/cmake)
  • 不,同样的错误。我应该先从文件中删除list(APPEND CMAKE_MODULE_PATH "E:/SITEGI/LIBRERIAS/PCL1.5.1/cmake")set(PCL_ROOT "E:/SITEGI/LIBRERIAS/PCL1.5.1") set(PCL_DIR "E:/SITEGI/LIBRERIAS/PCL1.5.1/cmake") 行吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-23
  • 2014-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多