1

I'm trying to compile a simple program using PCL, the linker can correctly link this instruction:

pcl::SHOTEstimationOMP<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352> shot_descriptor;

but whit this one:

pcl::SHOTColorEstimationOMP<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352> shot_descriptor;

I receive:

Linking CXX executable ../../../bin/gcc5_2/RGBDNN_PCL_Descriptord
CMakeFiles/RGBDNN_PCL_Descriptor.dir/__/__/src/pcl_descriptor.cpp.o:(.rodata._ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE[_ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE]+0x48): undefined reference to `pcl::SHOTColorEstimationOMP<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352, pcl::ReferenceFrame>::initCompute()'
CMakeFiles/RGBDNN_PCL_Descriptor.dir/__/__/src/pcl_descriptor.cpp.o:(.rodata._ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE[_ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE]+0x58): undefined reference to `pcl::SHOTColorEstimationOMP<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352, pcl::ReferenceFrame>::computeFeature(pcl::PointCloud<pcl::SHOT352>&)'
CMakeFiles/RGBDNN_PCL_Descriptor.dir/__/__/src/pcl_descriptor.cpp.o:(.rodata._ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE[_ZTVN3pcl22SHOTColorEstimationOMPINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE]+0x60): undefined reference to `pcl::SHOTColorEstimation<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352, pcl::ReferenceFrame>::computePointSHOT(int, std::vector<int, std::allocator<int> > const&, std::vector<float, std::allocator<float> > const&, Eigen::Matrix<float, -1, 1, 0, -1, 1>&)'
CMakeFiles/RGBDNN_PCL_Descriptor.dir/__/__/src/pcl_descriptor.cpp.o:(.rodata._ZTVN3pcl19SHOTColorEstimationINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE[_ZTVN3pcl19SHOTColorEstimationINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE]+0x58): undefined reference to `pcl::SHOTColorEstimation<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352, pcl::ReferenceFrame>::computeFeature(pcl::PointCloud<pcl::SHOT352>&)'
CMakeFiles/RGBDNN_PCL_Descriptor.dir/__/__/src/pcl_descriptor.cpp.o:(.rodata._ZTVN3pcl19SHOTColorEstimationINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE[_ZTVN3pcl19SHOTColorEstimationINS_12PointXYZRGBAENS_6NormalENS_7SHOT352ENS_14ReferenceFrameEEE]+0x60): undefined reference to `pcl::SHOTColorEstimation<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT352, pcl::ReferenceFrame>::computePointSHOT(int, std::vector<int, std::allocator<int> > const&, std::vector<float, std::allocator<float> > const&, Eigen::Matrix<float, -1, 1, 0, -1, 1>&)'
collect2: error: ld returned 1 exit status
cmake/pcl_descriptor/CMakeFiles/RGBDNN_PCL_Descriptor.dir/build.make:193: recipe for target '../bin/gcc5_2/RGBDNN_PCL_Descriptord' failed
make[2]: *** [../bin/gcc5_2/RGBDNN_PCL_Descriptord] Error 1
CMakeFiles/Makefile2:175: recipe for target 'cmake/pcl_descriptor/CMakeFiles/RGBDNN_PCL_Descriptor.dir/all' failed
make[1]: *** [cmake/pcl_descriptor/CMakeFiles/RGBDNN_PCL_Descriptor.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2
*** Failure: Exit code 2 ***

The two classes live in the same header and source file:

Header code shot_omp_8.h

Source code shot_omp_8.hpp

I have compiled the libraries by my own.

What is the problem?

ANSWER

Since the question was closed too quickly, i haven't had the time to explain why it is not a duplicate. The error was due to the default arguments of the two classes and not about the linked library.

The classes are declared in this way in the header:

 template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT352, typename PointRFT = pcl::ReferenceFrame>
 class SHOTEstimationOMP : public SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>

 template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT1344, typename PointRFT = pcl::ReferenceFrame>
 class SHOTColorEstimationOMP : public     SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>

You can't declare a SHOTColorEstrimationOMP with PointOutT equals to SHOT352 because it already has a specified type in the declaration.

Luca
  • 1,270
  • 1
  • 18
  • 34

0 Answers0