hku-mars / loam_livox

A robust LiDAR Odometry and Mapping (LOAM) package for Livox-LiDAR
GNU General Public License v2.0
1.45k stars 438 forks source link

Undefined referrence to cv::Mat::Mat() when compiling with Opencv major version 3.4.15 #92

Closed aniltotakura closed 3 years ago

aniltotakura commented 3 years ago

I have installed Open Cv from source (version 3.4) and set the Open_CV include directory to the path containing OpenCVConfig.cmake file Here is the ouptut of the catkin_make command: @ubuntu:/mnt/sharedVM/LOAM_LIVOX$ catkin_make Base path: /mnt/sharedVM/LOAM_LIVOX Source space: /mnt/sharedVM/LOAM_LIVOX/src Build space: /mnt/sharedVM/LOAM_LIVOX/build Devel space: /mnt/sharedVM/LOAM_LIVOX/devel Install space: /mnt/sharedVM/LOAM_LIVOX/install

Running command: "make cmake_check_build_system" in "/mnt/sharedVM/LOAM_LIVOX/build"

-- Using CATKIN_DEVEL_PREFIX: /mnt/sharedVM/LOAM_LIVOX/devel -- Using CMAKE_PREFIX_PATH: /mnt/sharedVM/LOAM_LIVOX/devel;/opt/gssi/lgprgps;/opt/ros/melodic -- This workspace overlays: /mnt/sharedVM/LOAM_LIVOX/devel;/opt/gssi/lgprgps;/opt/ros/melodic -- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2") -- Using PYTHON_EXECUTABLE: /usr/bin/python2 -- Using Debian Python package layout -- Using empy: /usr/bin/empy -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /mnt/sharedVM/LOAM_LIVOX/build/test_results -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python2 (found version "2.7.17") -- Using Python nosetests: /usr/bin/nosetests-2.7 -- catkin 0.7.29 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- ~~~~~~~~~~~~~ -- ~~ traversing 1 packages in topological order: -- ~~ - loam_livox -- ~~~~~~~~~~~~~ -- +++ processing catkin package: 'loam_livox' -- ==> add_subdirectory(loam_livox) CMake Error at loam_livox/CMakeLists.txt:7 (seset): Unknown CMake command "seset".

-- Configuring incomplete, errors occurred! See also "/mnt/sharedVM/LOAM_LIVOX/build/CMakeFiles/CMakeOutput.log". See also "/mnt/sharedVM/LOAM_LIVOX/build/CMakeFiles/CMakeError.log". Makefile:1216: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1 Invoking "make cmake_check_build_system" failed anilkumartotakura@ubuntu:/mnt/sharedVM/LOAM_LIVOX$ catkin_make Base path: /mnt/sharedVM/LOAM_LIVOX Source space: /mnt/sharedVM/LOAM_LIVOX/src Build space: /mnt/sharedVM/LOAM_LIVOX/build Devel space: /mnt/sharedVM/LOAM_LIVOX/devel Install space: /mnt/sharedVM/LOAM_LIVOX/install

Running command: "make cmake_check_build_system" in "/mnt/sharedVM/LOAM_LIVOX/build"

-- Using CATKIN_DEVEL_PREFIX: /mnt/sharedVM/LOAM_LIVOX/devel -- Using CMAKE_PREFIX_PATH: /mnt/sharedVM/LOAM_LIVOX/devel;/opt/gssi/lgprgps;/opt/ros/melodic -- This workspace overlays: /mnt/sharedVM/LOAM_LIVOX/devel;/opt/gssi/lgprgps;/opt/ros/melodic -- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2") -- Using PYTHON_EXECUTABLE: /usr/bin/python2 -- Using Debian Python package layout -- Using empy: /usr/bin/empy -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /mnt/sharedVM/LOAM_LIVOX/build/test_results -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python2 (found version "2.7.17") -- Using Python nosetests: /usr/bin/nosetests-2.7 -- catkin 0.7.29 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- ~~~~~~~~~~~~~ -- ~~ traversing 1 packages in topological order: -- ~~ - loam_livox -- ~~~~~~~~~~~~~ -- +++ processing catkin package: 'loam_livox' -- ==> add_subdirectory(loam_livox) -- Found OpenCV: /home/anilkumartotakura/opencv3.4/build (found suitable version "3.4.15", minimum required is "3.4.15") -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- Found installed version of Eigen: /usr/lib/cmake/eigen3 -- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3 -- Found required Ceres dependency: glog -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags -- Detected gflags version: 2.2.1 -- Found required Ceres dependency: gflags -- Found Ceres version: 1.13.0 installed in: /usr with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, CXSparse, SchurSpecializations, OpenMP] -- Boost version: 1.65.1 -- Found the following Boost libraries: -- system -- filesystem -- thread -- date_time -- iostreams -- serialization -- chrono -- atomic -- regex -- Could NOT find ensenso (missing: ENSENSO_LIBRARY ENSENSO_INCLUDE_DIR) WARNING io features related to ensenso will be disabled -- Could NOT find DAVIDSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR) WARNING io features related to davidSDK will be disabled -- Could NOT find DSSDK (missing: _DSSDK_LIBRARIES) WARNING io features related to dssdk will be disabled WARNING io features related to pcap will be disabled WARNING io features related to png will be disabled -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include:

-- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include:

WARNING io features related to libusb-1.0 will be disabled -- Could NOT find ensenso (missing: ENSENSO_LIBRARY ENSENSO_INCLUDE_DIR) WARNING visualization features related to ensenso will be disabled -- Could NOT find DAVIDSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR) WARNING visualization features related to davidSDK will be disabled -- Could NOT find DSSDK (missing: _DSSDK_LIBRARIES) WARNING visualization features related to dssdk will be disabled -- Could NOT find RSSDK (missing: _RSSDK_LIBRARIES) WARNING visualization features related to rssdk will be disabled -- looking for PCL_COMMON -- looking for PCL_OCTREE -- looking for PCL_IO -- looking for PCL_KDTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_MODELER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- PCL version: 1.8.1 -- Configuring done -- Generating done -- Build files have been written to: /mnt/sharedVM/LOAM_LIVOX/build

Running command: "make -j6 -l6" in "/mnt/sharedVM/LOAM_LIVOX/build"

Scanning dependencies of target opencv_version Scanning dependencies of target read_camera Scanning dependencies of target livox_scanRegistration Scanning dependencies of target livox_laserMapping [ 12%] Building CXX object loam_livox/CMakeFiles/opencv_version.dir/source/opencv_version.cpp.o [ 25%] Linking CXX executable /mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/opencv_version [ 25%] Built target opencv_version [ 37%] Building CXX object loam_livox/CMakeFiles/read_camera.dir/source/read_camera.cpp.o [ 50%] Linking CXX executable /mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/read_camera [ 62%] Building CXX object loam_livox/CMakeFiles/livox_scanRegistration.dir/source/laser_feature_extractor.cpp.o [ 62%] Built target read_camera [ 75%] Building CXX object loam_livox/CMakeFiles/livox_laserMapping.dir/source/laser_mapping.cpp.o In file included from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_feature_extractor.hpp:56:0, from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_feature_extractor.cpp:37: /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/livox_feature_extractor.hpp: In instantiation of ‘int Livox_laser::projection_scan_3d_2d(pcl::PointCloud&, std::vector&) [with T = pcl::PointXYZI]’: /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/livox_feature_extractor.hpp:755:13: required from ‘std::vector<pcl::PointCloud > Livox_laser::extract_laser_features(pcl::PointCloud&, double) [with T = pcl::PointXYZI]’ /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_feature_extractor.hpp:285:113: required from here /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/livox_feature_extractor.hpp:577:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if ( val_index < split_idx.size() - 2 )


In file included from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.cpp:37:0:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp: In member function ‘void Laser_mapping::service_loop_detection()’:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:1030:180: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
                     if( (last_keyframe->m_set_cell.size() - keyframe_vec[ his ]->m_set_cell.size() ) /  (last_keyframe->m_set_cell.size() + keyframe_vec[ his ]->m_set_cell.size())*0.1 )
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:969:51: warning: unused variable ‘ratio_non_zero_plane’ [-Wunused-variable]
             float                                 ratio_non_zero_plane = last_keyframe->m_ratio_nonzero_plane;
                                                   ^~~~~~~~~~~~~~~~~~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:970:51: warning: unused variable ‘ratio_non_zero_line’ [-Wunused-variable]
             float                                 ratio_non_zero_line = last_keyframe->m_ratio_nonzero_line;
                                                   ^~~~~~~~~~~~~~~~~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:981:19: warning: unused variable ‘sim_plane_res_cv’ [-Wunused-variable]
             float sim_plane_res_cv = 0, sim_plane_res = 0;
                   ^~~~~~~~~~~~~~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:982:19: warning: unused variable ‘sim_line_res_cv’ [-Wunused-variable]
             float sim_line_res_cv = 0, sim_line_res = 0;
                   ^~~~~~~~~~~~~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:876:13: warning: variable ‘last_update_index’ set but not used [-Wunused-but-set-variable]
         int last_update_index = 0;
             ^~~~~~~~~~~~~~~~~
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp: In member function ‘int Laser_mapping::process_new_scan()’:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:1554:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(m_keyframe_need_precession_list.size() > m_loop_closure_maximum_keyframe_in_wating_list)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:69:0,
                 from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.cpp:37:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/scene_alignment.hpp: In instantiation of ‘int Scene_alignment<PT_DATA_TYPE>::find_tranfrom_of_two_mappings(Maps_keyframe<PT_DATA_TYPE>*, Maps_keyframe<PT_DATA_TYPE>*, int, std::__cxx11::string) [with PT_DATA_TYPE = float; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/scene_alignment.hpp:266:45:   required from ‘int Scene_alignment<PT_DATA_TYPE>::find_tranfrom_of_two_mappings(std::shared_ptr<Maps_keyframe<PT_DATA_TYPE> >, std::shared_ptr<Maps_keyframe<PT_DATA_TYPE> >, int, std::__cxx11::string) [with PT_DATA_TYPE = float; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:1036:174:   required from here
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/scene_alignment.hpp:304:39: warning: variable ‘transform_R’ set but not used [-Wunused-but-set-variable]
         Eigen::Quaterniond            transform_R = Eigen::Quaterniond::Identity();
                                       ^~~~~~~~~~~
In file included from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:65:0,
                 from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.cpp:37:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp: In instantiation of ‘std::__cxx11::string Points_cloud_cell<DATA_TYPE>::to_json_string() [with DATA_TYPE = float; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1511:19:   required from ‘std::__cxx11::string Maps_keyframe<DATA_TYPE>::to_json_string(int&) [with DATA_TYPE = float; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1543:34:   required from ‘void Maps_keyframe<DATA_TYPE>::save_to_file(const string&, const string&) [with DATA_TYPE = float; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:975:98:   required from here
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:150:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( unsigned i = 0; i < point_number; i++ )
                               ~~^~~~~~~~~~~~~~
In file included from /usr/include/pcl-1.8/pcl/sample_consensus/sac_model.h:52:0,
                 from /usr/include/pcl-1.8/pcl/sample_consensus/sac.h:45,
                 from /usr/include/pcl-1.8/pcl/sample_consensus/ransac.h:44,
                 from /usr/include/pcl-1.8/pcl/registration/icp.h:45,
                 from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/scene_alignment.hpp:12,
                 from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.hpp:69,
                 from /mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/laser_mapping.cpp:37:
/usr/include/pcl-1.8/pcl/sample_consensus/model_types.h: In function ‘void __static_initialization_and_destruction_0(int, int)’:
/usr/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: warning: ‘pcl::SAC_SAMPLE_SIZE’ is deprecated: This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class [-Wdeprecated-declarations]
   SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
   ^~~~~~~~~~~~~~~
/usr/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: note: declared here
[ 87%] Linking CXX executable /mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/livox_scanRegistration
[ 87%] Built target livox_scanRegistration
[100%] Linking CXX executable /mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/livox_laserMapping
CMakeFiles/livox_laserMapping.dir/source/laser_mapping.cpp.o: In function `Maps_keyframe<float>::max_similiarity_of_two_image_opencv(Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, int)':
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1214: undefined reference to `cv::Mat::Mat()'
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1214: undefined reference to `cv::Mat::Mat()'
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1220: undefined reference to `cv::Mat::Mat()'
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1226: undefined reference to `cv::Mat::Mat()'
CMakeFiles/livox_laserMapping.dir/source/laser_mapping.cpp.o: In function `Maps_keyframe<float>::max_similiarity_of_two_image(Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, float)':
/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1172: undefined reference to `cv::Mat::Mat()'
CMakeFiles/livox_laserMapping.dir/source/laser_mapping.cpp.o:/mnt/sharedVM/LOAM_LIVOX/src/loam_livox/source/cell_map_keyframe.hpp:1172: more undefined references to `cv::Mat::Mat()' follow
collect2: error: ld returned 1 exit status
loam_livox/CMakeFiles/livox_laserMapping.dir/build.make:421: recipe for target '/mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/livox_laserMapping' failed
make[2]: *** [/mnt/sharedVM/LOAM_LIVOX/devel/lib/loam_livox/livox_laserMapping] Error 1
CMakeFiles/Makefile2:1562: recipe for target 'loam_livox/CMakeFiles/livox_laserMapping.dir/all' failed
make[1]: *** [loam_livox/CMakeFiles/livox_laserMapping.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j6 -l6" failed
aniltotakura commented 3 years ago

Solved it by specifying the directory of the OpenCVCmake.config file which is basically saying to use the opencv version used by cv_bridge

op114129 commented 2 years ago

could u tell me detailed files ,i am in trouble ,

tungtungyan commented 2 years ago

could u tell me detailed files ,i am in trouble ,

I have the same problem. Did you solve it?

LiuL0ngl0ng commented 12 months ago

The livox_laserMapping miss linked to Opencv library in the CMakeLists.txt, just appened the ${OpenCV_LIBS} to the target_link_libraries,liked below: target_link_libraries(livox_laserMapping ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES} ${OpenCV_LIBS})