open-rmf / rmf

Root repository for the RMF software
Apache License 2.0
225 stars 58 forks source link

rmf_traffic_ros2 is not compiling from source #146

Closed royito55 closed 2 years ago

royito55 commented 2 years ago

Self explanatory, I'm following the build instructions from source and I keep running into this error:

--- stderr: rmf_traffic_ros2                                                                              
/usr/bin/ld: /usr/local/lib/libyaml-cpp.a(emit.cpp.o): relocation R_X86_64_PC32 against symbol `_ZTVN4YAML12EventHandlerE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rmf_traffic_ros2.dir/build.make:1087: librmf_traffic_ros2.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:287: CMakeFiles/rmf_traffic_ros2.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

I've tried uninstalling everything and starting again but no luck.

I'm trying this with ROS2 Galactic

mxgrey commented 2 years ago

The root path of your libyaml-cpp (/usr/local) suggests that you may have manually built and installed a version of libyaml-cpp at some point in the past. Typically /usr/local is the default system install location for manually built packages.

The version of libyaml-cpp that you're linking against was compiled as a static library (see the .a file extension) and was compiled without position independent code (see the suggestion to recompile with fPIC).

The version of libyaml-cpp that we expect users to build against is libyaml-cpp-dev which is compiled as a shared library (.so) and will therefore have position independent code. That's necessary because we're trying to use libyaml-cpp from within shared libraries.

I can't know why you have a custom installation of libyaml-cpp on your machine, but you could consider deleting it and making sure you have libyaml-cpp-dev installed through apt-get.