I have gone through the internet for hours for similar cases to mine but I've tried all solutions and hasn't got my code working. I'm using a library called "vdo_slam" which has been built and can be found in /usr/local/include/vdo_slam
. In my project's CMakeList.txt
I can find_package(vdo_slam REQUIRED)
with no error. The only problem I have is at the end of "catkin_build" I get several of these "undefined reference to ...." as shown below. I have tried several solutions as listed below. All these undefined references are declared and defined inside the "vdo_slam" package. Any help is appreciated.
Known solutions I have tried:
I looked for classes and functions mentioned in the errors and see if there are pure virtual destructors as mentioned in here but they are all defined solidly.
I have tried to debug with "readelf" command as shown below referring to this. But i don't have the "libvdo_slam.so" which actually includes these functions in the error. I suppose i need to have "libvdo_slam.so" when i run this "readelf" command right? How can i add that?
Error message from "catkin_build":
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `typeinfo for VDO_SLAM::Visualizer2D'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `vtable for VDO_SLAM::Visualizer2D'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined referealtime_vdo_slam/CMakeFiles/ros_vdoslam_node.dir/all' failed
make[3]: *** [my_realtime_vdo_slam/CMakeFiles/ros_vdoslam_node.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j12 -l12" failede/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `VDO_SLAM::BoundingBox::BoundingBox(double, double, double, double)'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `VDO_SLAM::Scene::Scene()'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `VDO_SLAM::Visualizer2D::spinOnce(std::shared_ptr<VDO_SLAM::Scene>&)'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `VDO_SLAM::Scene::add_scene_object(std::shared_ptr<VDO_SLAM::SceneObject>&)'
/home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so: undefined reference to `VDO_SLAM::Visualizer2D::Visualizer2D(std::shared_ptr<VDO_SLAM::VisualizerParams>&)'
collect2: error: ld returned 1 exit status
my_realtime_vdo_slam/CMakeFiles/ros_vdoslam_node.dir/build.make:226: recipe for target '/home/tranks/testing_ws/devel/lib/my_realtime_vdo_slam/ros_vdoslam_node' failed
make[3]: *** [/home/tranks/testing_ws/devel/lib/my_realtime_vdo_slam/ros_vdoslam_node] Error 1
CMakeFiles/Makefile2:6593: recipe for target 'my_realtime_vdo_slam/CMakeFiles/ros_vdoslam_node.dir/all' failed
make[3]: *** [my_realtime_vdo_slam/CMakeFiles/ros_vdoslam_node.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j12 -l12" failed
$ readelf --dynamic /home/tranks/testing_ws/devel/lib/libmy_realtime_vdo_slam.so
Dynamic section at offset 0x161608 contains 42 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libimage_transport.so]
0x0000000000000001 (NEEDED) Shared library: [libcv_bridge.so]
0x0000000000000001 (NEEDED) Shared library: [libopencv_core.so.3.2]
0x0000000000000001 (NEEDED) Shared library: [libtf2_ros.so]
0x0000000000000001 (NEEDED) Shared library: [libtf2.so]
0x0000000000000001 (NEEDED) Shared library: [libroscpp.so]
0x0000000000000001 (NEEDED) Shared library: [libroscpp_serialization.so]
0x0000000000000001 (NEEDED) Shared library: [librosconsole.so]
0x0000000000000001 (NEEDED) Shared library: [librostime.so]
0x0000000000000001 (NEEDED) Shared library: [libboost_system.so.1.65.1]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libopencv_highgui.so.3.4]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2]
0x000000000000000e (SONAME) Library soname: [libmy_realtime_vdo_slam.so]
0x000000000000001d (RUNPATH) Library runpath: [/home/tranks/testing_ws/devel/lib:/opt/ros/melodic/lib:/usr/local/lib]
0x000000000000000c (INIT) 0xd0bd0
0x000000000000000d (FINI) 0x129494
0x0000000000000019 (INIT_ARRAY) 0x35f580
0x000000000000001b (INIT_ARRAYSZ) 56 (bytes)
0x000000000000001a (FINI_ARRAY) 0x35f5b8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x1f0
0x0000000000000005 (STRTAB) 0x2be68
0x0000000000000006 (SYMTAB) 0xa7d8
0x000000000000000a (STRSZ) 545696 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x362000
0x0000000000000002 (PLTRELSZ) 90336 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0xbaaf0
0x0000000000000007 (RELA) 0xb4058
0x0000000000000008 (RELASZ) 27288 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0xb3e98
0x000000006fffffff (VERNEEDNUM) 6
0x000000006ffffff0 (VERSYM) 0xb1208
0x000000006ffffff9 (RELACOUNT) 9
0x0000000000000000 (NULL) 0x0
This is my CMakeList.txt
:
cmake_minimum_required(VERSION 3.10)
project(my_realtime_vdo_slam)
find_package(catkin REQUIRED COMPONENTS
cv_bridge
flow_net
geometry_msgs
image_transport
mask_rcnn
message_generation
midas_ros
mono_depth_2
nav_msgs
python_service_starter
roscpp
sensor_msgs
std_msgs
tf
tf2
tf2_geometry_msgs
tf2_ros
tf2_sensor_msgs
vision_msgs
visualization_msgs
nodelet
message_filters
)
find_package(OpenCV)
find_package(vdo_slam REQUIRED)
## Generate messages in the 'msg' folder
add_message_files(
FILES
VdoSlamScene.msg
VdoSlamMap.msg
VdoSceneObject.msg
VdoInput.msg
)
generate_messages(
DEPENDENCIES
actionlib_msgs
geometry_msgs
std_msgs
sensor_msgs
mask_rcnn
vision_msgs
)
set(PROJECT_INCLUDE_DIRS
include
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${vdo_slam_INCLUDE_DIRS}
)
include_directories(
${PROJECT_INCLUDE_DIRS}
)
catkin_package(
INCLUDE_DIRS ${PROJECT_INCLUDE_DIRS}
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS
roscpp
image_transport
python_service_starter
std_msgs
tf
tf2
tf2_geometry_msgs
tf2_ros
tf2_sensor_msgs
nav_msgs
sensor_msgs
geometry_msgs
cv_bridge
flow_net
mask_rcnn
mono_depth_2
midas_ros
message_runtime
nodelet
message_filters
# DEPENDS system_lib
)
add_library(${PROJECT_NAME} SHARED
src/RosVdoSlam.cpp
src/utils/RosUtils.cpp
src/visualizer/RosVisualizer.cpp
src/visualizer/RosAsyncManager.cpp
src/tracking/HungarianSolver.cpp
src/tracking/SemanticTracker.cpp
)
target_link_libraries(${PROJECT_NAME} PUBLIC
${catkin_LIBRARIES}
${OpenCV_LIBS}
${vdo_slam_LIBRARIES}
)
#if(catkin_EXPORTED_LIBRARIES)
# add_dependencies(${PROJECT_NAME}
# ${catkin_EXPORTED_LIBRARIES}
# ${catkin_LIBRARIES}
# ${OpenCV_LIBS}
# ${vdo_slam_LIB_DIRS})
# endif()
# target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
# ${catkin_INCLUDE_DIRS}
# ${OpenCV_INCLUDE_DIRS}
# ${vdo_slam_INCLUDE_DIRS}
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
# $<INSTALL_INTERFACE:include>
# )
add_executable(ros_vdoslam_node
src/ros_vdoslam_node.cpp
)
target_link_libraries(ros_vdoslam_node
${catkin_LIBRARIES}
${OpenCV_LIBS}
${vdo_slam_LIB_DIRS}
${PROJECT_NAME}
)
if(catkin_EXPORTED_LIBRARIES)
add_dependencies(ros_vdoslam_node
${catkin_EXPORTED_LIBRARIES}
${catkin_LIBRARIES}
${OpenCV_LIBS}
${vdo_slam_LIBRARIES})
endif()