PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.86k stars 4.61k forks source link

Errors with Cluster Recognition Example Code #3309

Closed Archetype90 closed 5 years ago

Archetype90 commented 5 years ago

Your Environment

Context

Attempting to run the tutorial code, which can be found here: http://pointclouds.org/documentation/tutorials/vfh_recognition.php#vfh-recognition

I am not able to build the code as a result of this error.

Expected Behavior

As the tutorial suggests, I expect the code to build and compile.

Current Behavior

I created the source files and a CMake file from the tutorials. I have not posted it here, as the code tags were not working and it became messy. You can see it from the tutorial URL above.

I ran the 'cmake ..' command, but got the following error regarding FLANN:

`

CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindFLANN.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "FLANN", but
CMake did not find one.

Could not find a package configuration file provided by "FLANN" with any of
the following names:

FLANNConfig.cmake
flann-config.cmake

Add the installation prefix of "FLANN" to CMAKE_PREFIX_PATH or set
"FLANN_DIR" to a directory containing one of the above files.  If "FLANN"
provides a separate development package or SDK, be sure it has been
installed.`

I find this error confusing, as inside the /usr/include/flann directory there is no .cmake file and I cannot locate either of those files on my machine.

I did some research and someone suggested that the cmake file from the tutorial was very out of date and looked odd (unfortunately I lost the link). This person suggested using roughly the same .cmake file, but removing the references to FLANN. This can be seen here:

`

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(vfh_cluster_classifier)

find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

find_package(HDF5 REQUIRED)

include_directories(SYSTEM
  ${HDF5_INCLUDE_DIR}
)

add_executable(build_tree build_tree.cpp)
target_link_libraries(build_tree ${PCL_LIBRARIES} ${Boost_LIBRARIES}
                             ${HDF5_hdf5_LIBRARY})

add_executable(nearest_neighbors nearest_neighbors.cpp)
target_link_libraries(nearest_neighbors ${PCL_LIBRARIES} ${Boost_LIBRARIES} 
${HDF5_hdf5_LIBRARY})

`

The above .cmake file allowed me to cmake, but I get the following error when trying to make the project:

`

Scanning dependencies of target build_tree
[ 25%] Building CXX object CMakeFiles/build_tree.dir/build_tree.cpp.o
[ 50%] Linking CXX executable build_tree
/usr/bin/ld: CMakeFiles/build_tree.dir/build_tree.cpp.o: undefined reference to symbol 
'_ZN3MPI8Datatype4FreeEv'
//usr/lib/x86_64-linux-gnu/libmpi_cxx.so.20: error adding symbols: DSO missing from 
command line
collect2: error: ld returned 1 exit status
CMakeFiles/build_tree.dir/build.make:377: recipe for target 'build_tree' failed
make[2]: *** [build_tree] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/build_tree.dir/all' failed
make[1]: *** [CMakeFiles/build_tree.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

`

Code to Reproduce

I used the Debian PCL package, the code from the tutorial above, and the CMake file from the tutorial or listed above. Have not been able to successfully get the tutorial to build.

Possible Solution

taketwo commented 5 years ago

someone suggested that the cmake file from the tutorial was very out of date and looked odd (unfortunately I lost the link).

It's the other way round, whatever you see on the webpage is the most up-to-date code that is tested on CI to be compile with PCL master. You have an old release installed, so you should check out the tutorial code corresponding to that release. Easiest way is to open the 1.8.1 tag on GitHub: https://github.com/PointCloudLibrary/pcl/tree/pcl-1.8.1/doc/tutorials/content/sources/vfh_recognition.

Archetype90 commented 5 years ago

It's the other way round, whatever you see on the webpage is the most up-to-date code that is tested on CI to be compile with PCL master.

Thank you for your reply! The only push-back I would give to this is that the tutorial on the webpage (http://pointclouds.org/documentation/tutorials/index.php) state the versions required. The "Cluster Recognition and 6DOF Pose Estimation using VFH descriptors" tutorial that I am referencing states PCL version > 0.8, but does not mention different requirements for older/later versions. Since this is likely the main entry point for most new PCL users (myself included), it can be confusing when those tutorials have additional requirements outside of what is specified in the text.

you should check out the tutorial code corresponding to that release

Great suggestion! The FindFLANN.cmake gave me a lot of hope - and it did allow me to use the CMake file, untouched, from the link you provided. That fixed the FLANN error when running the cmake command.

Unfortunately, the second error still exists when making the project:

Scanning dependencies of target build_tree [ 25%] Building CXX object CMakeFiles/build_tree.dir/build_tree.cpp.o [ 50%] Linking CXX executable build_tree /usr/bin/ld: CMakeFiles/build_tree.dir/build_tree.cpp.o: undefined reference to symbol '_ZN3MPI8Datatype4FreeEv' //usr/lib/x86_64-linux-gnu/libmpi_cxx.so.20: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/build_tree.dir/build.make:378: recipe for target 'build_tree' failed make[2]: *** [build_tree] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/build_tree.dir/all' failed make[1]: *** [CMakeFiles/build_tree.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

I did a fair amount of searching for a solution both before and after posting this issue. I did come across another guy that was attempting to do a tutorial, came across the same FLANN problem I did, which was resolved, but than saw the same error as above. This thread can be found here:

http://www.pcl-users.org/Write-VFHSigniture308-histogram-into-a-pcd-file-td4042324.html

From that thread, a user suggested it is a problem with HDF5. A thread describing this can be found here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=686926

Unfortunately, from what I can tell, their recommendation is to uninstall an OpenMPI package, which seems to be critical to PCL (removing it would always have me remove PCL as well).

When testing against libhdf5-mpich2-dev, you should make sure that all OpenMPI libraries are removed (in particular libopenmpi-dev). Otherwise they take precedence over MPICH2 because of the alternatives priority.

I am a little unsure how to proceed. I am not clear if something is wrong with my setup environment, this is due to being on an older version of PCL (I used the debian package), if there is a problem with HDF5 that has bled into PCL, etc, etc? But, in any case, I could use some advice on how to proceed.

taketwo commented 5 years ago

it can be confusing when those tutorials have additional requirements outside of what is specified in the text.

You are right. Ideally, we should host old versions of tutorials and have a drop-down to navigate between them.

Regarding your problem at hand I'm afraid I'm not much of a help. The only suggestion I have is for you to try to link against hdf5 and mpi explicitly. That is, add to lines 23 and 27 in the main CMakeLists hdf5 mpi++ mpi

Archetype90 commented 5 years ago

Thank you again @taketwo for your response! I will leave the issue open for a few days while I attempt to the solve the problem and will post back if I find anything. Maybe another user will have experienced the same issue and have a solution.

Archetype90 commented 5 years ago

@taketwo I decided to build PCL from source. Happily, I was able to use the original code from the tutorial and successfully build the project using cmake. Unfortunately, I am now getting errors while trying to make. As you can see from the camke output below it successfully finds Eigen, Boost, FLANN, VTK, PCL, and HDF5.

cmake ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for module 'eigen3'
--   Found eigen3, version 3.3.4
-- Found Eigen: /usr/include/eigen3 (Required is at least version "3.1") 
-- Eigen found (include: /usr/include/eigen3, version: 3.3.4)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   filesystem
--   date_time
--   iostreams
--   serialization
--   regex
-- Checking for module 'flann'
--   Found flann, version 1.9.1
-- Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp.so  
-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.

** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- LIBUSB_1_LIBRARY (missing: LIBUSB_1_INCLUDE_DIR) 
** WARNING ** io features related to libusb-1.0 will be disabled
-- Found Qhull: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so  
-- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
-- looking for PCL_COMMON
-- Found PCL_COMMON: /usr/local/lib/libpcl_common.so  
-- looking for PCL_KDTREE
-- Found PCL_KDTREE: /usr/local/lib/libpcl_kdtree.so  
-- looking for PCL_OCTREE
-- Found PCL_OCTREE: /usr/local/lib/libpcl_octree.so  
-- looking for PCL_SEARCH
-- Found PCL_SEARCH: /usr/local/lib/libpcl_search.so  
-- looking for PCL_SAMPLE_CONSENSUS
-- Found PCL_SAMPLE_CONSENSUS: /usr/local/lib/libpcl_sample_consensus.so  
-- looking for PCL_FILTERS
-- Found PCL_FILTERS: /usr/local/lib/libpcl_filters.so  
-- looking for PCL_2D
-- Found PCL_2D: /usr/local/include/pcl-1.9  
-- looking for PCL_GEOMETRY
-- Found PCL_GEOMETRY: /usr/local/include/pcl-1.9  
-- looking for PCL_IO
-- Found PCL_IO: /usr/local/lib/libpcl_io.so  
-- looking for PCL_FEATURES
-- Found PCL_FEATURES: /usr/local/lib/libpcl_features.so  
-- looking for PCL_ML
-- Found PCL_ML: /usr/local/lib/libpcl_ml.so  
-- looking for PCL_SEGMENTATION
-- Found PCL_SEGMENTATION: /usr/local/lib/libpcl_segmentation.so  
-- looking for PCL_VISUALIZATION
-- Found PCL_VISUALIZATION: /usr/local/lib/libpcl_visualization.so  
-- looking for PCL_SURFACE
-- Found PCL_SURFACE: /usr/local/lib/libpcl_surface.so  
-- looking for PCL_REGISTRATION
-- Found PCL_REGISTRATION: /usr/local/lib/libpcl_registration.so  
-- looking for PCL_KEYPOINTS
-- Found PCL_KEYPOINTS: /usr/local/lib/libpcl_keypoints.so  
-- looking for PCL_TRACKING
-- Found PCL_TRACKING: /usr/local/lib/libpcl_tracking.so  
-- looking for PCL_RECOGNITION
-- Found PCL_RECOGNITION: /usr/local/lib/libpcl_recognition.so  
-- looking for PCL_STEREO
-- Found PCL_STEREO: /usr/local/lib/libpcl_stereo.so  
-- looking for PCL_OUTOFCORE
-- Found PCL_OUTOFCORE: /usr/local/lib/libpcl_outofcore.so  
-- looking for PCL_PEOPLE
-- Found PCL_PEOPLE: /usr/local/lib/libpcl_people.so  
-- Found PCL: pcl_common;pcl_kdtree;pcl_octree;pcl_search;pcl_sample_consensus;pcl_filters;pcl_io;pcl_features;pcl_ml;pcl_segmentation;pcl_visualization;pcl_surface;pcl_registration;pcl_keypoints;pcl_tracking;pcl_recognition;pcl_stereo;pcl_outofcore;pcl_people;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so;vtkChartsCore;vtkCommonColor;vtkCommonDataModel;vtkCommonMath;vtkCommonCore;vtksys;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkInfovisCore;vtkFiltersExtraction;vtkCommonExecutionModel;vtkFiltersCore;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkftgl;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkIOCore;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkImagingColor;vtkRenderingVolume;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL;vtkRenderingOpenGL;FLANN::FLANN (Required is at least version "1.2") 
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.0.1")  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/

But when attempting to make the project, I get the follow errors:

make
[ 25%] Linking CXX executable build_tree
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<char>()':
build_tree.cpp:(.text+0x5): undefined reference to `H5open'
build_tree.cpp:(.text+0xc): undefined reference to `H5T_NATIVE_SCHAR_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned char>()':
build_tree.cpp:(.text+0x17): undefined reference to `H5open'
build_tree.cpp:(.text+0x1e): undefined reference to `H5T_NATIVE_UCHAR_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<short>()':
build_tree.cpp:(.text+0x29): undefined reference to `H5open'
build_tree.cpp:(.text+0x30): undefined reference to `H5T_NATIVE_SHORT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned short>()':
build_tree.cpp:(.text+0x3b): undefined reference to `H5open'
build_tree.cpp:(.text+0x42): undefined reference to `H5T_NATIVE_USHORT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<int>()':
build_tree.cpp:(.text+0x4d): undefined reference to `H5open'
build_tree.cpp:(.text+0x54): undefined reference to `H5T_NATIVE_INT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned int>()':
build_tree.cpp:(.text+0x5f): undefined reference to `H5open'
build_tree.cpp:(.text+0x66): undefined reference to `H5T_NATIVE_UINT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<long>()':
build_tree.cpp:(.text+0x71): undefined reference to `H5open'
build_tree.cpp:(.text+0x78): undefined reference to `H5T_NATIVE_LONG_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned long>()':
build_tree.cpp:(.text+0x83): undefined reference to `H5open'
build_tree.cpp:(.text+0x8a): undefined reference to `H5T_NATIVE_ULONG_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<float>()':
build_tree.cpp:(.text+0x95): undefined reference to `H5open'
build_tree.cpp:(.text+0x9c): undefined reference to `H5T_NATIVE_FLOAT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<double>()':
build_tree.cpp:(.text+0xa7): undefined reference to `H5open'
build_tree.cpp:(.text+0xae): undefined reference to `H5T_NATIVE_DOUBLE_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<long double>()':
build_tree.cpp:(.text+0xb9): undefined reference to `H5open'
build_tree.cpp:(.text+0xc0): undefined reference to `H5T_NATIVE_LDOUBLE_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `void flann::save_to_file<float>(flann::Matrix<float> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x36): undefined reference to `H5Eset_auto2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x4a): undefined reference to `H5check_version'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x4f): undefined reference to `H5open'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x6d): undefined reference to `H5Fopen'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x8e): undefined reference to `H5check_version'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x93): undefined reference to `H5open'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0xb6): undefined reference to `H5Fcreate'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x122): undefined reference to `H5Screate_simple'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x13c): undefined reference to `H5Screate_simple'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x17f): undefined reference to `H5Dcreate2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x1b3): undefined reference to `H5Dopen2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x226): undefined reference to `H5Dwrite'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x26e): undefined reference to `H5Sclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x27a): undefined reference to `H5Sclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x286): undefined reference to `H5Dclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x292): undefined reference to `H5Fclose'
collect2: error: ld returned 1 exit status
CMakeFiles/build_tree.dir/build.make:192: recipe for target 'build_tree' failed
make[2]: *** [build_tree] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/build_tree.dir/all' failed
make[1]: *** [CMakeFiles/build_tree.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I have searched for examples of this issue and most people seem to report that it is a problem with HDF5 and FLANN (as the errors suggest). I am fairly certain this is not a PCL problem, but I have now build PCL from source, following all instructions and getting all dependencies, but still have an error with the tutorial.

Would you have any feedback on how to fix this issue? Should I be installing HDF5 and FLANN from source (I had used their debian packages for all dependencies, which had worked fine up until this tutorial code).

Thanks!

Archetype90 commented 5 years ago

As another small piece of info, here is the ccmake from the directory of the tutorial. The main thing I am concerned with is the flann_DIR-NOTFOUND, where as PCL and VTK dir had no problem. But I am too inexperienced to know if this is normal.

CMAKE_BUILD_TYPE                                                              
 CMAKE_INSTALL_PREFIX             /usr/local                                   
 FLANN_INCLUDE_DIR                /usr/include                                 
 FLANN_LIBRARY                    /usr/lib/x86_64-linux-gnu/libflann_cpp.so    
 FLANN_LIBRARY_DEBUG              FLANN_LIBRARY_DEBUG-NOTFOUND                 
 HDF5_C_LIBRARY_dl                /usr/lib/x86_64-linux-gnu/libdl.so           
 HDF5_C_LIBRARY_hdf5              /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5
 HDF5_C_LIBRARY_m                 /usr/lib/x86_64-linux-gnu/libm.so            
 HDF5_C_LIBRARY_pthread           /usr/lib/x86_64-linux-gnu/libpthread.so      
 HDF5_C_LIBRARY_sz                /usr/lib/x86_64-linux-gnu/libsz.so           
 HDF5_C_LIBRARY_z                 /usr/lib/x86_64-linux-gnu/libz.so            
 LIBUSB_1_INCLUDE_DIR             LIBUSB_1_INCLUDE_DIR-NOTFOUND                
 LIBUSB_1_LIBRARY                 LIBUSB_1_LIBRARY-NOTFOUND                    
 PCL_DIR                          /usr/local/share/pcl-1.9                     
 QHULL_LIBRARY                    /usr/lib/x86_64-linux-gnu/libqhull.so        
 QHULL_LIBRARY_DEBUG              /usr/lib/x86_64-linux-gnu/libqhull.so        
 VTK_DIR                          /usr/lib/cmake/vtk-6.3                       
 flann_DIR                        flann_DIR-NOTFOUND                        
taketwo commented 5 years ago

Have you tried my last suggestion?

The only suggestion I have is for you to try to link against hdf5 and mpi explicitly. That is, add to lines 23 and 27 in the main CMakeLists hdf5 mpi++ mpi

flann_DIR should not be a problem.

Please also post output of make VERBOSE=1.

Archetype90 commented 5 years ago

If I'm honest, I am relatively new to using CMake and was not clear on exactly what I should be doing to implement your previous suggestion. And my apologizes, since I assumed that these new errors were separate from that solution.

Here is the result from make VERBOSE=1:

make VERBOSE=1
/usr/bin/cmake -H/home/pcl-test -B/home/pcl-test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pcl-test/build/CMakeFiles /home/pcl-test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pcl-test/build'
make -f CMakeFiles/build_tree.dir/build.make CMakeFiles/build_tree.dir/depend
make[2]: Entering directory '/home/pcl-test/build'
cd /home/pcl-test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pcl-test /home/pcl-test /home/pcl-test/build /home/pcl-test/build /home/pcl-test/build/CMakeFiles/build_tree.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pcl-test/build'
make -f CMakeFiles/build_tree.dir/build.make CMakeFiles/build_tree.dir/build
make[2]: Entering directory '/home/pcl-test/build'
[ 25%] Linking CXX executable build_tree
/usr/bin/cmake -E cmake_link_script CMakeFiles/build_tree.dir/link.txt --verbose=1
/usr/bin/c++       -rdynamic CMakeFiles/build_tree.dir/build_tree.cpp.o  -o build_tree  -L/usr/local/lib -Wl,-rpath,/usr/local/lib /usr/local/lib/libpcl_surface.so /usr/local/lib/libpcl_keypoints.so /usr/local/lib/libpcl_tracking.so /usr/local/lib/libpcl_recognition.so /usr/local/lib/libpcl_stereo.so /usr/local/lib/libpcl_outofcore.so /usr/local/lib/libpcl_people.so -lboost_system -lboost_filesystem -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_regex -lqhull -lfreetype -lz -ljpeg -lpng -ltiff -lboost_system -lboost_filesystem -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_regex /usr/lib/x86_64-linux-gnu/libflann_cpp.so /usr/local/lib/libpcl_registration.so /usr/local/lib/libpcl_segmentation.so /usr/local/lib/libpcl_features.so /usr/local/lib/libpcl_filters.so /usr/local/lib/libpcl_sample_consensus.so /usr/lib/x86_64-linux-gnu/libvtkChartsCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInfovisCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOLegacy-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOPLY-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingLOD-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkViewsContext2D-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkViewsCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInteractionWidgets-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersModeling-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInteractionStyle-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersHybrid-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingGeneral-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingSources-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingAnnotation-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingColor-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingVolume-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingContextOpenGL-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingContext2D-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingFreeType-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkftgl-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingOpenGL-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonColor-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersExtraction-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersStatistics-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingFourier-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkalglib-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersSources-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersGeneral-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonComputationalGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingHybrid-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkDICOMParser-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonDataModel-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonMisc-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonSystem-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtksys-6.3.so.6.3.0 -ldl /usr/lib/x86_64-linux-gnu/libvtkCommonTransforms-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonMath-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkmetaio-6.3.so.6.3.0 -lGLU -lGL -lSM -lICE -lX11 -lXext -lXt /usr/local/lib/libpcl_ml.so /usr/local/lib/libpcl_visualization.so /usr/local/lib/libpcl_search.so /usr/local/lib/libpcl_kdtree.so /usr/local/lib/libpcl_io.so /usr/local/lib/libpcl_octree.so /usr/local/lib/libpcl_common.so -lqhull -lfreetype -lz -ljpeg -lpng -ltiff 
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<char>()':
build_tree.cpp:(.text+0x5): undefined reference to `H5open'
build_tree.cpp:(.text+0xc): undefined reference to `H5T_NATIVE_SCHAR_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned char>()':
build_tree.cpp:(.text+0x17): undefined reference to `H5open'
build_tree.cpp:(.text+0x1e): undefined reference to `H5T_NATIVE_UCHAR_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<short>()':
build_tree.cpp:(.text+0x29): undefined reference to `H5open'
build_tree.cpp:(.text+0x30): undefined reference to `H5T_NATIVE_SHORT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned short>()':
build_tree.cpp:(.text+0x3b): undefined reference to `H5open'
build_tree.cpp:(.text+0x42): undefined reference to `H5T_NATIVE_USHORT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<int>()':
build_tree.cpp:(.text+0x4d): undefined reference to `H5open'
build_tree.cpp:(.text+0x54): undefined reference to `H5T_NATIVE_INT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned int>()':
build_tree.cpp:(.text+0x5f): undefined reference to `H5open'
build_tree.cpp:(.text+0x66): undefined reference to `H5T_NATIVE_UINT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<long>()':
build_tree.cpp:(.text+0x71): undefined reference to `H5open'
build_tree.cpp:(.text+0x78): undefined reference to `H5T_NATIVE_LONG_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<unsigned long>()':
build_tree.cpp:(.text+0x83): undefined reference to `H5open'
build_tree.cpp:(.text+0x8a): undefined reference to `H5T_NATIVE_ULONG_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<float>()':
build_tree.cpp:(.text+0x95): undefined reference to `H5open'
build_tree.cpp:(.text+0x9c): undefined reference to `H5T_NATIVE_FLOAT_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<double>()':
build_tree.cpp:(.text+0xa7): undefined reference to `H5open'
build_tree.cpp:(.text+0xae): undefined reference to `H5T_NATIVE_DOUBLE_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `long flann::(anonymous namespace)::get_hdf5_type<long double>()':
build_tree.cpp:(.text+0xb9): undefined reference to `H5open'
build_tree.cpp:(.text+0xc0): undefined reference to `H5T_NATIVE_LDOUBLE_g'
CMakeFiles/build_tree.dir/build_tree.cpp.o: In function `void flann::save_to_file<float>(flann::Matrix<float> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x36): undefined reference to `H5Eset_auto2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x4a): undefined reference to `H5check_version'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x4f): undefined reference to `H5open'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x6d): undefined reference to `H5Fopen'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x8e): undefined reference to `H5check_version'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x93): undefined reference to `H5open'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0xb6): undefined reference to `H5Fcreate'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x122): undefined reference to `H5Screate_simple'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x13c): undefined reference to `H5Screate_simple'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x17f): undefined reference to `H5Dcreate2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x1b3): undefined reference to `H5Dopen2'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x226): undefined reference to `H5Dwrite'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x26e): undefined reference to `H5Sclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x27a): undefined reference to `H5Sclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x286): undefined reference to `H5Dclose'
build_tree.cpp:(.text._ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_[_ZN5flann12save_to_fileIfEEvRKNS_6MatrixIT_EERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_]+0x292): undefined reference to `H5Fclose'
collect2: error: ld returned 1 exit status
CMakeFiles/build_tree.dir/build.make:192: recipe for target 'build_tree' failed
make[2]: *** [build_tree] Error 1
make[2]: Leaving directory '/home/pcl-test/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/build_tree.dir/all' failed
make[1]: *** [CMakeFiles/build_tree.dir/all] Error 2
make[1]: Leaving directory '/home/pcl-test/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Archetype90 commented 5 years ago

OK, I have solved it. I am not entirely clear where I went wrong in my setup vs. the CMake file of the tutorial, but that CMake file will not work. Something about not finding the right HDF5 version, but I am not entirely clear why it works for others, but not me. I have updated the CMake file to the following and I am able to build and run the tutorial! Thanks for all your help @taketwo , closing the issue and hopefully this will help someone in the future.

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(vfh_cluster_classifier)

find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

# Find right hdf5 file
include (CheckIncludeFile)
check_include_file ("hdf5/serial/hdf5.h" HDF5_SERIAL)
if (HDF5_SERIAL)
  set (HDF5 "hdf5_serial")
  include_directories ("/usr/include/hdf5/serial")
endif (HDF5_SERIAL)

find_package(FLANN REQUIRED)

include_directories(SYSTEM
)

add_executable(build_tree build_tree.cpp)
target_link_libraries(build_tree ${PCL_LIBRARIES} ${Boost_LIBRARIES}
                                 FLANN::FLANN ${HDF5})

add_executable(nearest_neighbors nearest_neighbors.cpp)
target_link_libraries(nearest_neighbors ${PCL_LIBRARIES} ${Boost_LIBRARIES} FLANN::FLANN ${HDF5})
Archetype90 commented 5 years ago

It occurred to me I should not close this issue, as it is still that - an issue. Although it is solved, I suspect other people are having this same problem?

taketwo commented 5 years ago

I believe this is the most straightforward solution to the problem you faced:

diff --git a/doc/tutorials/content/sources/vfh_recognition/CMakeLists.txt b/doc/tutorials/content/sources/vfh_recognition/CMakeLists.txt
index 82c3f690e..7d25d3f68 100644
--- a/doc/tutorials/content/sources/vfh_recognition/CMakeLists.txt
+++ b/doc/tutorials/content/sources/vfh_recognition/CMakeLists.txt
@@ -16,7 +16,7 @@ include_directories(SYSTEM

 add_executable(build_tree build_tree.cpp)
 target_link_libraries(build_tree ${PCL_LIBRARIES} ${Boost_LIBRARIES}
-                                 FLANN::FLANN ${HDF5_hdf5_LIBRARY})
+                                 FLANN::FLANN ${HDF5_LIBRARIES})

 add_executable(nearest_neighbors nearest_neighbors.cpp)
-target_link_libraries(nearest_neighbors ${PCL_LIBRARIES} ${Boost_LIBRARIES} FLANN::FLANN ${HDF5_hdf5_LIBRARY})
+target_link_libraries(nearest_neighbors ${PCL_LIBRARIES} ${Boost_LIBRARIES} FLANN::FLANN ${HDF5_LIBRARIES})

If you are interested, here is the logic. The errors that you posted:

build_tree.cpp:(.text+0x5): undefined reference to `H5open'
build_tree.cpp:(.text+0xc): undefined reference to `H5T_NATIVE_SCHAR_g'

indicate that HDF5 symbols are not found during linking of tutorial executables. This may have different reasons (in the order of probability): 1) we are not looking for them 2) we are looking for them in a wrong place 3) they are genuinely wrong and don't exist anywhere.

To check item 1 we need to see the actual command used for linking. This is what make call with verbose option provides. There we see:

/usr/bin/c++       -rdynamic CMakeFiles/build_tree.dir/build_tree.cpp.o  -o build_tree  -L/usr/local/lib -Wl,-rpath,/usr/local/lib /usr/local/lib/libpcl_surface.so /usr/local/lib/libpcl_keypoints.so /usr/local/lib/libpcl_tracking.so /usr/local/lib/libpcl_recognition.so /usr/local/lib/libpcl_stereo.so /usr/local/lib/libpcl_outofcore.so /usr/local/lib/libpcl_people.so -lboost_system -lboost_filesystem -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_regex -lqhull -lfreetype -lz -ljpeg -lpng -ltiff -lboost_system -lboost_filesystem -lboost_date_time -lboost_iostreams -lboost_serialization -lboost_regex /usr/lib/x86_64-linux-gnu/libflann_cpp.so /usr/local/lib/libpcl_registration.so /usr/local/lib/libpcl_segmentation.so /usr/local/lib/libpcl_features.so /usr/local/lib/libpcl_filters.so /usr/local/lib/libpcl_sample_consensus.so /usr/lib/x86_64-linux-gnu/libvtkChartsCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInfovisCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOLegacy-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOPLY-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingLOD-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkViewsContext2D-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkViewsCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInteractionWidgets-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersModeling-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkInteractionStyle-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersHybrid-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingGeneral-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingSources-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingAnnotation-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingColor-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingVolume-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingContextOpenGL-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingContext2D-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingFreeType-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkftgl-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingOpenGL-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkRenderingCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonColor-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersExtraction-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersStatistics-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingFourier-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkalglib-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersSources-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersGeneral-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkFiltersCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonComputationalGeometry-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingHybrid-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkImagingCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkDICOMParser-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkIOCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonDataModel-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonMisc-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonSystem-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtksys-6.3.so.6.3.0 -ldl /usr/lib/x86_64-linux-gnu/libvtkCommonTransforms-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonMath-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkCommonCore-6.3.so.6.3.0 /usr/lib/x86_64-linux-gnu/libvtkmetaio-6.3.so.6.3.0 -lGLU -lGL -lSM -lICE -lX11 -lXext -lXt /usr/local/lib/libpcl_ml.so /usr/local/lib/libpcl_visualization.so /usr/local/lib/libpcl_search.so /usr/local/lib/libpcl_kdtree.so /usr/local/lib/libpcl_io.so /usr/local/lib/libpcl_octree.so /usr/local/lib/libpcl_common.so -lqhull -lfreetype -lz -ljpeg -lpng -ltiff 

There are tons of libraries being linked in (-lXXXX and /full/path/lib.so arguments), but nothing that looks like an HDF5 library. It follows that we have a mistake in CMake configuration. Looking at the CMake script, we see that our targets are linked with ${HDF5_hdf5_LIBRARY}. This is a CMake variable, likely populated by the find_package(HDF5) command. What can go wrong here? Maybe this variable does not even exist, or maybe its contents are not what we expect. At this point we may either print it to see what's inside, or check CMake documentation for HDF5 package. Strangely enough, such variable is not listed there... so in the CMake script it's set to an empty string and effectively we don't link our executable with anything. According to the documentation, there is HDF5_LIBRARIES variable though, so we should use it.

Archetype90 commented 5 years ago

Fantastic explanation! Thank you very much @taketwo - I hope your boss watches these threads and is giving you a raise for how helpful you are! I wish there was a way to private message on GitHub. I would love to steal 10-30 minutes of your time if you are ever available to chat on a program like Slack, Skype, or Discord. Picking your brain would likely be of immense value - I have such novice questions, but it is difficult to find the information. But, I realize your time is likely limited and very valuable.

The good news is, with your help, I am now able to run every sample piece of code I have found. And I am slowly piecing things together.

Closing the issue, as it is resolved, and was very specific to my setup.