我要被气死了。
前提条件:
CMake
MSVC 2022(务必装这个)
VSCode以及相关的C++,CMake插件等
安装步骤:
-
去PCL的Release这里下载类似“PCL-1.14.1-AllInOne-msvc2022-win64.exe”名称的exe,安装过程中要求为所有用户写入环境变量。
-
找个地方新建空文件夹,新建这些文件,注意文件名也要一样
pcd_write.cpp:
// pcd_write.cpp
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int main()
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.resize (cloud.width * cloud.height);
for (auto& point: cloud)
{
point.x = 1024 * rand () / (RAND_MAX + 1.0f);
point.y = 1024 * rand () / (RAND_MAX + 1.0f);
point.z = 1024 * rand () / (RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.size () << " data points to test_pcd.pcd." << std::endl;
for (const auto& point: cloud)
std::cerr << " " << point.x << " " << point.y << " " << point.z << std::endl;
return (0);
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.4 REQUIRED)
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})
message(STATUS "PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
-
打开VSCode中的设置,直接搜索“cmake generator”,然后如图填入东西:
-
保存后开始CMake编译,然后你应该会看在输出看到这个:
......
[cmake] -- PCL_INCLUDE_DIRS: C:/Program Files/PCL 1.14.1/include/pcl-1.14;C:/Program Files/PCL 1.14.1/3rdParty/Eigen3/include/eigen3;C:/Program Files/PCL 1.14.1/3rdParty/Boost/include/boost-1_84;C:/Program Files/OpenNI2/Include
......
把这些目录全部复制到剪贴板
- 打开C/C++配置(不是VSC设置里面那个配置,是类似这样的)
下达到这里,然后黏贴你刚刚复制的东西,再做一些微调,让它看起来像这样:
现在理论上可以运行了
标签:DIRS,1.14,VSCode,cloud,PCL,使用,include,pcd From: https://www.cnblogs.com/Lemon-GPU/p/18345854