ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Build ROS package with -fPIC

asked 2016-08-25 15:05:02 -0500

Koralgoll gravatar image

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.

edit retag flag offensive close merge delete

Comments

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.

yujing gravatar image yujing  ( 2018-10-04 09:08:17 -0500 )edit

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"

ahendrix gravatar image ahendrix  ( 2019-01-23 13:13:34 -0500 )edit

You may want to try linking against the vtk shared libraries (.so files) instead of the static libraries (.a files)

ahendrix gravatar image ahendrix  ( 2019-01-23 13:14:13 -0500 )edit

@ahendrix@Koralgoll I'm having the same problem, have you found any solutions?

0novanta gravatar image 0novanta  ( 2019-03-25 13:02:29 -0500 )edit

Similar issue here was resolved by installing the development packages: https://answers.ros.org/question/3193... .

ahendrix gravatar image ahendrix  ( 2019-03-25 15:23:01 -0500 )edit

Thank you, already solved by downloading the library and modifying the CMakeCache.txt file

0novanta gravatar image 0novanta  ( 2019-03-26 06:30:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-01-23 12:43:54 -0500

tfoote gravatar image

CMake has a property for targets POSITION_INDEPENDENT_CODE that you can set globally or per target.

https://stackoverflow.com/a/38297422/...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-08-25 15:05:02 -0500

Seen: 1,224 times

Last updated: Jan 23 '19