pcl EuclideanClusterExtraction中的链接错误

Linking error in pcl EuclideanClusterExtraction

本文关键字:链接 错误 EuclideanClusterExtraction pcl      更新时间:2023-10-16

当尝试运行pcl提供的示例时,我遇到了最奇怪的链接错误:

http://www.pointclouds.org/documentation/tutorials/cluster_extraction.php

我已经把错误缩小到以下一行:

ec.extract (cluster_indices);

当我删除这一行时,没有链接错误,否则我得到一堆看起来像这样的:

/usr/local/lib/libpcl_search.a(organized.cpp.o): In function `pcl::search::OrganizedNeighbor<pcl::PointXYZL>::computeCameraMatrix(Eigen::Matrix<float, 3, 3, 0, 3, 3>&) const':
organized.cpp:(.text._ZNK3pcl6search17OrganizedNeighborINS_9PointXYZLEE19computeCameraMatrixERN5Eigen6MatrixIfLi3ELi3ELi0ELi3ELi3EEE
[_ZNK3pcl6search17OrganizedNeighborINS_9PointXYZLEE19computeCameraMatrixERN5Eigen6MatrixIfLi3ELi3ELi0ELi3ELi3EEE]+0xc): 
undefined reference to `pcl::getCameraMatrixFromProjectionMatrix(Eigen::Matrix<float, 3, 4, 1, 3, 4> const&, Eigen::Matrix<float, 3, 3, 0, 3, 3>&)'

ecpcl::EuclideanClusterExtraction<pcl::PointXYZ>类型,所有相关联的点云也均采用pcl::PointXYZ模板。

我之前有一个非常类似的错误,事实证明是因为我试图使用pcl::PointXY与不支持的SampleConsesus库。

为了尝试解决这个问题,我在libpcl_search.a链接库上使用了nm,包含的值看起来像这样:

_ZNK3pcl6search17OrganizedNeighborINS_11PointNormalEE19computeCameraMatrixERN5Eigen6MatrixIfLi3ELi3ELi0ELi3ELi3EEE

接近所需的包含函数,但似乎PointXYZ实现不存在?我怎样才能知道情况是否如此?为什么?

所以看起来cmake正在与依赖关系作斗争。我确信这是因为我们被迫加入pcl的方式。我们正在使用一个名为QNX的操作系统,这意味着CMakeLists.txt需要看起来像这样:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set (CMAKE_C_COMPILER /usr/qnx650/host/qnx6/x86/usr/bin/gcc)
set (CMAKE_CXX_COMPILER /usr/qnx650/host/qnx6/x86/usr/bin/g++)
project(cluster_extraction)
find_package(PCL 1.7 REQUIRED)
include_directories(/usr/local/include /usr/local/include/pcl-1.7)
link_directories(/usr/local/lib)
add_definitions(${PCL_DEFINITIONS})
add_executable (cluster_extraction testEuclideanclustering.cpp)
target_link_libraries (cluster_extraction ${PCL_LIBRARIES})

如果我在${PCL_LIBRARIES}的链接之后添加pcl_search的直接链接,那么它将编译。看来我们需要为pcl制定自己的cmake规则。