building error: undefined reference to symbol '_ZN3tbb8internal23allocate_via_handler_v3Em'
liang0724s opened this issue · 2 comments
【Error log】
Errors << linkalibr:make /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/logs/linkalibr/build.make.001.log
/usr/bin/ld: CMakeFiles/ros_calib_init_optimizer.dir/src/ros_calib_init_optimizer.cpp.o: undefined reference to symbol '_ZN3tbb8internal23allocate_via_handler_v3Em'
//usr/lib/x86_64-linux-gnu/libtbb.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [/home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/devel/.private/linkalibr/lib/linkalibr/ros_calib_init_optimizer] Error 1
make[1]: *** [CMakeFiles/ros_calib_init_optimizer.dir/all] Error 2
make: *** [all] Error 2
【Prerequisites】:
Ubuntu 16.04 system
GTSAM - 4.0.3
openVINS-2.3
TBB: sudo apt-get install intel-tbb-2020.3-912
【GTSAM Configuration Options】
-- ================ Configuration Options ======================
-- CMAKE_CXX_COMPILER_ID type : GNU
-- CMAKE_CXX_COMPILER_VERSION : 5.5.0
-- CMake version : 3.18.5
-- CMake generator : Unix Makefiles
-- CMake build tool : /usr/bin/make
-- Build flags
-- Build Tests : Enabled
-- Build examples with 'make all' : Enabled
-- Build timing scripts with 'make all': Disabled
-- Build Docs : Enabled
-- Build shared GTSAM libraries : Enabled
-- Put build type in library name : Enabled
-- Build libgtsam_unstable : Enabled
-- Build for native architecture : Enabled
-- Build type : Release
-- C compilation flags : -O3 -DNDEBUG
-- C++ compilation flags : -Wno-misleading-indentation -O3 -DNDEBUG
-- GTSAM_COMPILE_FEATURES_PUBLIC : cxx_std_11
-- GTSAM_COMPILE_OPTIONS_PRIVATE : -Wall;-fPIC;$<$CONFIG:Debug:-g;-fno-inline>;$<$CONFIG:Release:-O3>;$<$CONFIG:Timing:-g;-O3>;$<$CONFIG:Profiling:-O3>;$<$CONFIG:RelWithDebInfo:-g;-O3>;-Wno-unused-local-typedefs
-- GTSAM_COMPILE_OPTIONS_PUBLIC : -march=native
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE : $<$CONFIG:Debug:_DEBUG;EIGEN_INITIALIZE_MATRICES_BY_NAN>;$<$CONFIG:Release:NDEBUG>;$<$CONFIG:Timing:NDEBUG;ENABLE_TIMING>;$<$CONFIG:Profiling:NDEBUG>;$<$CONFIG:RelWithDebInfo:NDEBUG>
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_DEBUG : -g;-fno-inline
-- GTSAM_COMPILE_OPTIONS_PUBLIC_DEBUG :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_DEBUG : _DEBUG;EIGEN_INITIALIZE_MATRICES_BY_NAN
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_DEBUG :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_RELEASE : -O3
-- GTSAM_COMPILE_OPTIONS_PUBLIC_RELEASE :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_RELEASE : NDEBUG
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELEASE :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_TIMING : -g;-O3
-- GTSAM_COMPILE_OPTIONS_PUBLIC_TIMING :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_TIMING : NDEBUG;ENABLE_TIMING
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_TIMING :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_PROFILING : -O3
-- GTSAM_COMPILE_OPTIONS_PUBLIC_PROFILING :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_PROFILING : NDEBUG
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_PROFILING :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_RELWITHDEBINFO : -g;-O3
-- GTSAM_COMPILE_OPTIONS_PUBLIC_RELWITHDEBINFO :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_RELWITHDEBINFO : NDEBUG
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELWITHDEBINFO :
-- GTSAM_COMPILE_OPTIONS_PRIVATE_MINSIZEREL :
-- GTSAM_COMPILE_OPTIONS_PUBLIC_MINSIZEREL :
-- GTSAM_COMPILE_DEFINITIONS_PRIVATE_MINSIZEREL :
-- GTSAM_COMPILE_DEFINITIONS_PUBLIC_MINSIZEREL :
-- Use System Eigen : ON (Using version: 3.2.92)
-- Use Intel TBB : Yes
-- Eigen will use MKL : MKL not found
-- Eigen will use MKL and OpenMP : OpenMP found but GTSAM_WITH_EIGEN_MKL is disabled
-- Default allocator : TBB
-- Cheirality exceptions enabled : YES
-- Build with ccache : No
-- Packaging flags
-- CPack Source Generator : TGZ
-- CPack Generator : TGZ
-- GTSAM flags
-- Quaternions as default Rot3 : Disabled
-- Runtime consistency checking : Disabled
-- Rot3 retract is full ExpMap : Enabled
-- Pose3 retract is full ExpMap : Enabled
-- Deprecated in GTSAM 4 allowed : Enabled
-- Point3 is typedef to Vector3 : Disabled
-- Metis-based Nested Dissection : Enabled
-- Use tangent-space preintegration: Enabled
-- Build Wrap : Enabled
-- MATLAB toolbox flags
-- Install MATLAB toolbox : Disabled
-- Cython toolbox flags
-- Install Cython toolbox : Disabled
【Q&A】
What's the problem?How to resolve this error?
catkin build INFO:
(base) ubuntu@minzhus:~/receive/Lidar_imu_calib/TAMU/catkin_ws_ov$ catkin build -DDISABLE_MATPLOTLIB=OFF
Profile: default
Extending: [cached] /opt/ros/kinetic
Workspace: /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov
Build Space: [exists] /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/build
Devel Space: [exists] /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/devel
Install Space: [unused] /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/install
Log Space: [exists] /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/logs
Source Space: [exists] /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/src
DESTDIR: [unused] None
Devel Space Layout: linked
Install Space Layout: None
Additional CMake Args: -DDISABLE_MATPLOTLIB=OFF
Additional Make Args: None
Additional catkin Make Args: None
Internal Make Job Server: True
Cache Job Environments: False
Whitelisted Packages: None
Blacklisted Packages: None
Workspace configuration appears valid.
[build] Found '7' packages in 0.0 seconds.
[build] Package table is up to date.
Starting >>> imuPacket
Starting >>> ndt_omp
Starting >>> ov_core
Starting >>> ov_data
Starting >>> ov_eval
Finished <<< ov_core [ 0.1 seconds ]
Finished <<< imuPacket [ 0.1 seconds ]
Finished <<< ov_eval [ 0.1 seconds ]
Finished <<< ndt_omp [ 0.1 seconds ]
Starting >>> linkalibr
Finished <<< ov_data [ 0.1 seconds ]
Starting >>> ov_msckf
Finished <<< ov_msckf [ 0.1 seconds ]
Errors << linkalibr:make /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/logs/linkalibr/build.make.001.log
/usr/bin/ld: CMakeFiles/ros_calib_init_optimizer.dir/src/ros_calib_init_optimizer.cpp.o: undefined reference to symbol '_ZN3tbb8internal23allocate_via_handler_v3Em'
//usr/lib/x86_64-linux-gnu/libtbb.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [/home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/devel/.private/linkalibr/lib/linkalibr/ros_calib_init_optimizer] Error 1
make[1]: *** [CMakeFiles/ros_calib_init_optimizer.dir/all] Error 2
make: *** [all] Error 2
cd /home/minzhus/receive/Lidar_imu_calib/TAMU/catkin_ws_ov/build/linkalibr; catkin build --get-env linkalibr | catkin env -si /usr/bin/make --jobserver-fds=6,7 -j; cd -
..................................................................................................................................................................
Failed << linkalibr:make [ Exited with code 2 ]
Failed <<< linkalibr [ 18.2 seconds ]
[build] Summary: 6 of 7 packages succeeded.
[build] Ignored: None.
[build] Warnings: None.
[build] Abandoned: None.
[build] Failed: 1 packages failed.
[build] Runtime: 18.5 seconds total.
I have done it.
The problem is libtbb library is linked unsuccessfully.
Add the following content to CMakeLists.txt of linkalibr:
**set(LIB_TBB_DIR /usr/lib/x86_64-linux-gnu)
add_library(libtbb SHARED IMPORTED)
set_target_properties(libtbb PROPERTIES IMPORTED_LOCATION ${LIB_TBB_DIR}/libtbb.so.2)
target_link_libraries(ros_calib_init_optimizer
gtsam
${CERES_LIBRARIES}
${catkin_LIBRARIES}
libtbb)**