introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.79k stars 787 forks source link

Failed to build rtabmap with VTK-9.1.0 and PCL-1.12.1 #804

Open jiapei100 opened 2 years ago

jiapei100 commented 2 years ago
/usr/bin/ld: cannot find -lvtkGUISupportQt
/usr/bin/ld: cannot find -lg2o::solver_cholmod
/usr/bin/ld: cannot find -lg2o::solver_csparse
/usr/bin/ld: cannot find -lg2o::csparse_extension
cdb0y511 commented 2 years ago

Hi, for vtk you need to enable qt-group support in cmake-gui, and you also need to check g2o cmake information too.

matlabbe commented 2 years ago

This commit should fix the g2o errors.

I'll check for PCL/VTK (longer to test)...

matlabbe commented 2 years ago

Make sure VTK 9.1.0 is built with Qt (not that I tested on Ubutnu bionic, which comes with Qt5.9.5):

Things to be careful: if you build dependencies from source, make sure to build all them with or without -march=native flag (edit: also found that SSE and AVX flags would have to be the same too) to avoid Eigen related crashes on runtime (when they are installed from binaries, they are without -march=native).

With -march=native

(Note that PCL built from source is enabling it by default)

You would have those flags when doing cmake of rtabmap:

cd rtabmap/build
cmake ..
...
--   PCL_COMPILE_OPTIONS = -msse4.2;-mfpmath=sse;-march=native;-mavx2
...

From the VERBOSE=1 build of each dependency: pcl: -msse4.2 -mfpmath=sse -march=native -mavx2 -fopenmp -O2 -g -DNDEBUG -fPIC g2o: -march=native -fPIC -msse2 -msse3 -msse4.1 -msse4.2 gtsam: -O3 -DNDEBUG -fPIC -march=native

Without -march=native, AVX and SSE flags

The most compatible version is by disabling any optimizations:

Related issue: https://github.com/introlab/rtabmap/issues/637