#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/console/parse.h>
#include <pcl/common/transforms.h>
#include <pcl/visualization/pcl_visualizer.h>
int main(int argc, char* argv[]){
//pcl::PointCloud<pcl::PointXYZ>::Ptr s___(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointCloud<pcl::PointXYZ> s__;
std::vector<int> filenames = pcl::console::parse_file_extension_argument(argc,argv,".pcd");
pcl::io::loadPCDFile(argv[filenames[0]], s__);
return 0;
}
无论是使用共享指针还是 PointCloud 对象本身,当程序命中(在运行时)“loadPCDfile”行时,我都会收到分段错误错误!
这是当我单独使用 gcc 编译时没有错误。为什么?PS > 我不想使用包装器
Ubuntu 18.04 pcl 1.11 cuda 11 gcc 7.5 特征 3.7
而 cmake 是,
cmake_minimum_required(VERSION 3.20.0)
project(t LANGUAGES CXX CUDA)
find_package(Eigen3 QUIET)
find_package(PCL 1.11 REQUIRED)
find_package(CUDA)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--ptxas-options=-v;-std=c++17)
include_directories(
${PCL_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
if(NOT EIGEN3_FOUND)
# Fallback to cmake_modules
find_package(cmake_modules REQUIRED)
find_package(Eigen REQUIRED)
set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES}) # Not strictly necessary as Eigen is head only
# Possibly map additional variables to the EIGEN3_ prefix.
else()
set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()
add_executable (t t.cu)
target_link_libraries(t
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${PCL_LIBRARIES})
然后当制作可执行的 t.out 时,我有一个名为 map.pcd 的 pcd 文件,然后我就运行
./t.out map.pcd
并且发生分段错误