Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compile error] "Cannot add pcl::ColorGradientModality<pcl::PointXYZRGB> as member" #3839

Closed
ghost opened this issue Mar 31, 2020 · 6 comments
Labels
kind: compile error Type of issue module: filters needs: pr merge Specify why not closed/merged yet

Comments

@ghost
Copy link

ghost commented Mar 31, 2020

Issue Summary
I'm trying to create a wrapper class for pcl::LINEMOD which requires me to make pcl::ColorGradientModality and pcl::SurfaceNormalModality my member variables. I include the following headers and my .h file:

#include <pcl/recognition/color_gradient_modality.h>
#include <pcl/recognition/surface_normal_modality.h>

but the build fails with the following errors:

CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `Eigen::internal::binary_evaluator<Eigen::CwiseBinaryOp<Eigen::internal::scalar_quotient_op<float, float>, Eigen::Block<Eigen::Matrix<float, 3, 3, 0, 3, 3>, 1, 3, false> const, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<float>, Eigen::Matrix<float, 1, 3, 1, 1, 3> const> const>, Eigen::internal::IndexBased, Eigen::internal::IndexBased, float, float>::binary_evaluator(Eigen::CwiseBinaryOp<Eigen::internal::scalar_quotient_op<float, float>, Eigen::Block<Eigen::Matrix<float, 3, 3, 0, 3, 3>, 1, 3, false> const, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<float>, Eigen::Matrix<float, 1, 3, 1, 1, 3> const> const> const&)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:243: multiple definition of `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:243: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:263: multiple definition of `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:263: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowNonDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:283: multiple definition of `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneRowNonDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:283: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColNonDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:317: multiple definition of `pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::convolveOneColNonDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:317: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneRowDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:351: multiple definition of `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneRowDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:351: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:368: multiple definition of `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:368: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneRowNonDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:385: multiple definition of `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneRowNonDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:385: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneColNonDense(int, int)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:391: multiple definition of `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::convolveOneColNonDense(int, int)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:391: first defined here
CMakeFiles/ubt_detector.dir/src/ubt_detector.cpp.o: In function `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::makeInfinite(pcl::RGB&)':
/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:397: multiple definition of `pcl::filters::Convolution<pcl::RGB, pcl::RGB>::makeInfinite(pcl::RGB&)'
CMakeFiles/ubt_detector.dir/src/main.cpp.o:/usr/local/include/pcl-1.10/pcl/filters/impl/convolution.hpp:397: first defined here
collect2: error: ld returned 1 exit status

To Reproduce
Create simple class with pcl::ColorGradientModality as a member.

Screenshots/Code snippets/Build information

My implementation is along the following lines

MyClass.h

...
#include<pcl/recognition/color_gradient_modality.h>
...

class MyClass
{
public:
    // Member methods
protected:
   ...
   pcl::ColorGradientModality<pcl::PointXYZRGB> color_grad_mod_;
   ...
}

MyClass.cpp

...
MyClass::SomeMethod()
{
    color_grad_mod_.setInputCloud(input_cloud);
    color_grad_mod_.processInputData();
}
...

Your Environment (please complete the following information):

  • OS: Ubuntu 18.04
  • Compiler: clang6.0.0
  • PCL Version: HEAD
  • PCL Type: Installed/Compiled from source

If PCL was compiled from source or failure in compiling PCL itself:

  • GPU, Kinfu, CUDA enabled? No
  • List and Version of dependencies used: Boost 1.65.1, Eigen3

Possible Solution

Based on this thread the solutions seems to be to separate convolution.h member methods into a separate .cpp file instead of an

#include <pcl/recognition/impl/convolution.hpp>

at the end of the file. Similarly for color_grad_modality.h as well.

@ghost ghost added kind: compile error Type of issue status: triage Labels incomplete labels Mar 31, 2020
@kunaltyagi
Copy link
Member

PCL Type: Installed/Compiled from source

Did you try using PCL_NO_PRECOMPILE?

@ghost
Copy link
Author

ghost commented Apr 1, 2020

@kunaltyagi

The #include <pcl/filters/impl/convolution.hpp> was not wrapped in #define guard. Even if I add the guard, the flag PCL_NO_PRECOMPILE is already set in pcl_config.h.in

@kunaltyagi
Copy link
Member

The #include <pcl/filters/impl/convolution.hpp> was not wrapped in #define guard

That's not needed. The issue is with the full specialization. A work-around can be inline before the offending functions. If that works, please report back 😄

Even if I add the guard, the flag PCL_NO_PRECOMPILE

This is unrelated to the error (based on my diagnosis), but you can't set it... You need to compile PCL with this flag.

@kunaltyagi kunaltyagi added module: filters needs: author reply Specify why not closed/merged yet and removed status: triage Labels incomplete labels Apr 1, 2020
@ghost
Copy link
Author

ghost commented Apr 1, 2020

@kunaltyagi I'm new to CMake, can you explain how I can compile PCL with this flag?

@kunaltyagi
Copy link
Member

It's not needed in this case (but it's as simple as <cmake-command> -DPCL_NO_PRECOMPILE) as the error is caused by something else.

Please try to modify PCL source code at the offending lines (adding inline along with the return type), (then installing PCL again or using sudoedit) and then compiling your code again.

@ghost
Copy link
Author

ghost commented Apr 1, 2020

@kunaltyagi
The inline work-around worked!! Thanks so much! Just for the record:

I made makeInfinite inline in convolution.h

The function template for

convolveRolDense
convolveRowNonDense
convolveColDense
convolveColNonDense

are inline'd but they have SPECIALIZATION in convolution.hpp that are not. So I inline'd those and my class now builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: compile error Type of issue module: filters needs: pr merge Specify why not closed/merged yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants