I had this error with cortex_control package when building the ros_workspace for Isaac and solved it

Hello everyone,

I had this yaml-cpp related error when building the ros_workspace of Isaac sim

/usr/bin/ld: /usr/local/lib/libyaml-cpp.a(convert.cpp.o): relocation R_X86_64_PC32 against symbol `_ZN4YAML11InvalidNodeC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' 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]: *** [/home/mohamed/.local/share/ov/pkg/isaac_sim-2022.1.0/ros_workspace/devel/.private/cortex_control/lib/libcortex_control.so] Error 1
make[1]: *** [CMakeFiles/cortex_control.dir/all] Error 2
make: *** [all] Error 2

It is a linking error, and as shown in the error message, yaml-cpp should use the -fPIC option.

The way I solved it is by installing yaml-cpp from source and used the required flag as follows

git clone https://github.com/jbeder/yaml-cpp.git
cd yaml-cpp
env CFLAGS='-fPIC' CXXFLAGS='-fPIC' cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build -v
make install

This solved the above error with the cortex_control when building the ros_workspace.

I hope this will help someone who encounters the same error.

Best,