Build ROS package with -fPIC
I am trying to build ROS package but I am getting this error:
Linking CXX shared library ../lib/libdvo_ros.so
/usr/bin/ld: /usr/lib/libvtkWrappingTools-6.2.a(vtkParse.tab.c.o): relocation R_X86_64_32S against '.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/libvtkWrappingTools-6.2.a(vtkParse.tab.c.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
I want to run cmake with -fPIC flag, so I added it to CMakeList.txt:
set(CMAKE_C_FLAGS "-fPIC" CACHE STRING "compile flags" FORCE)
set(CMAKE_CXX_FLAGS "-fPIC" CACHE STRING "compile flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-shared" CACHE STRING "linking flags" FORCE)
But it does not seem to work. The error still occurs. I can see that -fPIC flag was added to CMakeCache.txt in build folder of my ROS package. What I am missing here?
I am using catkin kinetic and building in catkin workspace on Ubuntu 16.
Hi: koralgoll, I got this problem too, and I also change the CMakeList.txt and without working. So how can I do for this problem? Thankyou.
I seem to remember seeing something like this before, and remember that the
-fPIC
warning was misleading, and not actually the solution. Maybe search google for "relocation R_X86_64_32S against '.rodata' can not be used when making a shared object; recompile with -fPIC"You may want to try linking against the vtk shared libraries (.so files) instead of the static libraries (.a files)
@ahendrix@Koralgoll I'm having the same problem, have you found any solutions?
Similar issue here was resolved by installing the development packages: https://answers.ros.org/question/3193... .
Thank you, already solved by downloading the library and modifying the CMakeCache.txt file