0
$\begingroup$

Rosanswers logo

I've done this steps like 7 times. I re-install foxy like 7 times too. I fail to see why it's not working now, it was working another day. This colcon build error drives me crazy

I was following this tutorial: https://emanual.robotis.com/docs/en/platform/turtlebot3/quick-start/

I'm on foxy version

bwuk@robot:~/turtlebot3_ws/src$  rosversion -d
foxy

python:

/usr/bin/python

I was able to following until colcon build --symlink -install under 1.1.4 install turtbot3 package

*bwuk@robot:~/turtlebot3_ws/src$ colcon build --symlink-install
Starting >>> turtlebot3_msgs
Starting >>> turtlebot3_description
Starting >>> turtlebot3_cartographer
Starting >>> turtlebot3_navigation2
Starting >>> turtlebot3_teleop
Finished <<< turtlebot3_description [0.60s] 
Finished <<< turtlebot3_cartographer [0.63s]
Finished <<< turtlebot3_navigation2 [0.62s]
--- stderr: turtlebot3_msgs 

/usr/bin/ld: /usr/local/lib/libpython3.9.a(abstract.o): relocation R_X86_64_PC32 against symbol `_Py_NotImplementedStruct' 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/turtlebot3_msgs__python.dir/build.make:193: rosidl_generator_py/turtlebot3_msgs/libturtlebot3_msgs__python.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:240: CMakeFiles/turtlebot3_msgs__python.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

---

Failed <<< turtlebot3_msgs [0.72s, exited with code 2]
Aborted <<< turtlebot3_teleop [0.77s] 
Summary: 3 packages finished [1.14s]
 1 package failed: turtlebot3_msgs
 1 package aborted: turtlebot3_teleop
 1 package had stderr output: turtlebot3_msgs
 4 packages not processed*

What am I missing here? It was working very well last week. How did it happen?


Originally posted by kak13 on ROS Answers with karma: 113 on 2021-03-17

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

This is old. The issue was that I kept download the different version of ROS2.

Select the correct ROS2 version would solve the issue. Please feel free to comment here if you have similar issue as this and we will troubleshoot this together.

Closing this now


Originally posted by kak13 with karma: 113 on 2021-07-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ecentri_adam on 2021-09-03:
Similar problem here, the error I kept getting: /usr/bin/ld: /usr/local/lib/libpython3.7m.a(call.o): relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC

The '.a' at the end of the problem file means the linker's trying to compile against something that's not a shared object ('.so') file. This likely means the linker's looking in the wrong directory.

What fixed this for me (run in workspace): colcon build --packages-select tutorial_interfaces --cmake-clean-cache --cmake-clean-first --cmake-force-configure --ament-cmake-args -DCMAKE_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/"

NOTE: your library path (CMAKE_LIBRARY_PATH) may need to point someplace else, look for the .so version of the problem file (eg: libpython3.7m.a is the issue, so find libpython3.7m.so on your system, install libpython37-dev or similar if needed). ALSO: make sure you've sourced your setup.bash file first!

$\endgroup$
0
$\begingroup$

Rosanswers logo

Eventually I found two ways to fix this recompile with -fPIC type of error. In my case, I think it was occurring because I was trying to link LIB_A (a static library) into LIB_B ( a shared library).

  • Method 1: add the fPIC flag to the CMakeLists of LIB_A, like this:

set(CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_FLAGS}")

  • Method 2: make LIB_A a shared library, too, like this:

add_library(thread_priority SHARED src/thread_priority.cpp)

as opposed to add_library(thread_priority STATIC src/thread_priority.cpp)


Originally posted by AndyZe with karma: 2331 on 2022-08-27

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.