visp_ros icon indicating copy to clipboard operation
visp_ros copied to clipboard

Failed to build: librealsense2 DSO missing from command line

Open kamiradi opened this issue 2 years ago • 4 comments

Hi, I am having the following build errors when trying to build visp_ros. Any suggestions?

/usr/bin/ld: CMakeFiles/tutorial-franka-real-pbvs-apriltag.dir/tutorial/franka/real-robot/tutorial-franka-real-pbvs-apriltag.cpp.o: undefined reference to symbol 'rs2_get_failed_function' //usr/local/lib/librealsense2.so.2.50: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/tutorial-franka-real-pbvs-apriltag.dir/build.make:205: recipe for target '/home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/tutorial-franka-real-pbvs-apri
ltag' failed
make[2]: *** [/home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/tutorial-franka-real-pbvs-apriltag] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/tutorial-franka-real-pbvs-apriltag.dir/all' failed
make[1]: *** [CMakeFiles/tutorial-franka-real-pbvs-apriltag.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 95%] Linking CXX executable /home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/tutorial-franka-real-ibvs-apriltag
/usr/bin/ld: CMakeFiles/tutorial-franka-real-ibvs-apriltag.dir/tutorial/franka/real-robot/tutorial-franka-real-ibvs-apriltag.cpp.o: undefined reference to symbol 'rs2_get_failed_function'
//usr/local/lib/librealsense2.so.2.50: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/tutorial-franka-real-ibvs-apriltag.dir/build.make:205: recipe for target '/home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/tutorial-franka-real-ibvs-apr$ltag' failed
make[2]: *** [/home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/tutorial-franka-real-ibvs-apriltag] Error 1
CMakeFiles/Makefile2:994: recipe for target 'CMakeFiles/tutorial-franka-real-ibvs-apriltag.dir/all' failed
make[1]: *** [CMakeFiles/tutorial-franka-real-ibvs-apriltag.dir/all] Error 2
[ 97%] Linking CXX executable /home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/visp_ros_pbvs_blob_node
[100%] Linking CXX executable /home/panda/Documents/panda_vision_ws/devel_isolated/visp_ros/lib/visp_ros/visp_ros_blob_tracker_node
[100%] Built target visp_ros_pbvs_blob_node
[100%] Built target visp_ros_blob_tracker_node
Makefile:138: recipe for target 'all' failed

kamiradi avatar Aug 12 '22 15:08 kamiradi

Hi on further investigation, I see that the real problem seems to be that CMake doesn't configure properly. I am using CMake 3.1.0, ROS kinetic, Ubuntu 16. CMake seems to be using cc and c++ compilers. Furthermore, i have also added the following lines to the package CMakeLists.txt

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads)

I get the following output in my CMakeError.log

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTryCompileExec211407289/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec211407289.dir/build.make CMakeFiles/cmTryCompileExec211407289.dir/build
make[1]: Entering directory '/home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp'
/opt/cmake/bin/cmake -E cmake_progress_report /home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec211407289.dir/CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/cmTryCompileExec211407289.dir/CheckSymbolExists.c.o   -c /home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec211407289
/opt/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec211407289.dir/link.txt --verbose=1
/usr/bin/cc      CMakeFiles/cmTryCompileExec211407289.dir/CheckSymbolExists.c.o  -o cmTryCompileExec211407289 -rdynamic 
CMakeFiles/cmTryCompileExec211407289.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec211407289.dir/build.make:88: recipe for target 'cmTryCompileExec211407289' failed
make[1]: *** [cmTryCompileExec211407289] Error 1
make[1]: Leaving directory '/home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec211407289/fast' failed
make: *** [cmTryCompileExec211407289/fast] Error 2

File /home/panda/Documents/panda_vision_ws/build/visp_ros/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

I have also tried with other versions of CMake, but i get the same error. pthread does not seem to be linking to a very specific test of cmake. If you look at the CMakeError.log, the -pthread flag is not being passed, hence the error. Would you be able to see exactly which version of CMake you were using to build the package?

kamiradi avatar Aug 17 '22 16:08 kamiradi

I suspect that you have ViSP binary packages installed (maybe ros-distro-visp package installed in /opt/ros/distro/... or libvisp-dev package in /usr/lib) besides ViSP installed from source (in /usr/local/lib).

If this is the case, keep only ViSP installed from source by removing binary packages.

To check if I'm right:

$ sudo updatedb
$ locate libvisp_core

fspindle avatar Aug 25 '22 06:08 fspindle

Hi I have an issue after installing ros_humble_visp and then following the instructions on the main page to install visp_visioon for ros. Here is the error I see:

Screenshot from 2023-11-29 09-47-07

Can someone help me out? I also run

$ sudo updatedb $ locate libvisp_core

To check and I see:

Screenshot from 2023-11-29 09-49-33

In this case should I also remove the binaries and try again?

Thanks a lot!

shrutichakraborty avatar Nov 29 '23 08:11 shrutichakraborty

It seems that image_proc ros2 package is not installed.

$ sudo apt install ros-<distro>-image-proc

fspindle avatar Nov 29 '23 09:11 fspindle