ros2 执行colcon build时报如下错误:
~/workspace/dev_ws » colcon build john@john-pc
Starting >>> turtlesim
--- stderr: turtlesim
/usr/bin/ld: /usr/local/lib/libpython3.7m.a(boolobject.o): relocation R_X86_64_PC32 against symbol `_Py_FalseStruct' 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]: *** [rosidl_generator_py/turtlesim/libturtlesim__python.so] Error 1
make[1]: *** [CMakeFiles/turtlesim__python.dir/all] Error 2
make: *** [all] Error 2
---
Failed <<< turtlesim [ Exited with code 2 ]
Summary: 0 packages finished [1.36s]
1 package failed: turtlesim
1 package had stderr output: turtlesim
解决办法:
重新编译安装python,带上参数–enable-shared,configure参数如下:
./configure --enable-optimizations --with-ssl --enable-shared
然后需要清理当前的文件夹后重新colcon build