【发布时间】:2012-11-29 19:28:31
【问题描述】:
我正在尝试使用 CMakeLists.txt 文件编译带有 QtCreator 的 PCL 示例。 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