norlab-ulaval / libpointmatcher

An Iterative Closest Point (ICP) library for 2D and 3D mapping in Robotics
BSD 3-Clause "New" or "Revised" License
1.58k stars 542 forks source link

build error: no match for operator++ / operator- #488

Open cryptix opened 2 years ago

cryptix commented 2 years ago

Does somebody know what this is about?

/build/source/pointmatcher/DataPointsFilters/Gestalt.cpp:499:9: error: no match for 'operator++' (operand type is 'Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double> >::type {aka Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double>}')
         ++(numOfValues(indices(0,it), indices(1,it)));
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/source/pointmatcher/DataPointsFilters/Gestalt.cpp:514:71: error: no match for 'operator-' (operand types are 'Eigen::DenseCoeffsBase<Eigen::Matrix<double, -1, 1>, 1>::Scalar {aka double}' and 'Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double> >::type {aka Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double>}')
         gestaltVariances(indices(0,it), indices(1,it)) += (heights(it)-gestaltMeans(indices(0,it), indices(1,it))) * (heights(it)-gestaltMeans(indices(0,it), indices(1,it)));
                                                           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/source/pointmatcher/DataPointsFilters/Gestalt.cpp:514:130: error: no match for 'operator-' (operand types are 'Eigen::DenseCoeffsBase<Eigen::Matrix<double, -1, 1>, 1>::Scalar {aka double}' and 'Eigen::internal::enable_if<true, Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double> >::type {aka Eigen::IndexedView<Eigen::Matrix<double, -1, -1>, double, double>}')
         gestaltVariances(indices(0,it), indices(1,it)) += (heights(it)-gestaltMeans(indices(0,it), indices(1,it))) * (heights(it)-gestaltMeans(indices(0,it), indices(1,it)));

This is on linux using gcc 7.5, 8 and 10 and eigen 3.4.0 boost 1.5.5 and 1.6.5.

smileyenot983 commented 2 years ago

i fixed it by changing following lines in CMakeLists.txt:

lines 132-150 into:

#--------------------
# DEPENDENCY: eigen 3
#--------------------
# find_path(EIGEN_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
#   HINTS  ENV EIGEN3_INC_DIR
#          ENV EIGEN3_DIR
#   PATHS  Eigen/Core
#          /usr/local/include
#          /usr/include
#   PATH_SUFFIXES include eigen3 eigen
#   DOC "Directory containing the Eigen3 header files"
# )

# Suppress Eigen's warning by adding it to the system's library
# include_directories(SYSTEM "${EIGEN_INCLUDE_DIR}")

#TODO: this should be a more standard way
find_package(Eigen3 REQUIRED)
message("-- eigen3 , version ${EIGEN_VERSION}")

and lines 394-396:

target_link_libraries(pointmatcher PUBLIC Eigen3::Eigen ${Boost_LIBRARIES})
target_link_libraries(pointmatcher PRIVATE Eigen3::Eigen ${libnabo_LIBRARIES})
target_link_libraries(pointmatcher PRIVATE Eigen3::Eigen ${EXTERNAL_LIBS})

According to docs in Eigen, there are 2 ways to use Eigen:

  1. add headers as include
  2. add them into cmake through find_package