colcon build --symlink-install can't find '__main__' module; ld: cannot find -lpthreads
On Fedora 32, ROS 10.1, following these instructions, running colcon build --symlink-install
errors out with the below:
-- BUILD_SHARED_LIBS is on
/usr/local/bin/anaconda3/bin/python: can't find '__main__' module in '/usr/local/bin/anaconda3/lib/python3.7/site-packages/em'
CMake Error at cmake/safe_execute_process.cmake:11 (message):
execute_process(/root/ros_catkin_ws/build/catkin/catkin_generated/env_cached.sh
"/usr/local/bin/anaconda3/bin/python"
"/usr/local/bin/anaconda3/lib/python3.7/site-packages/em" "--raw-errors"
"-F"
"/root/ros_catkin_ws/build/catkin/catkin_generated/pkg.develspace.context.pc.py"
"-o" "/root/ros_catkin_ws/build/catkin/devel/lib/pkgconfig/catkin.pc"
"/root/ros_catkin_ws/src/catkin/cmake/em/pkg.pc.em") returned error code 1
Call Stack (most recent call first):
cmake/em_expand.cmake:25 (safe_execute_process)
cmake/catkin_package.cmake:327 (em_expand)
cmake/catkin_package.cmake:102 (_catkin_package)
CMakeLists.txt:11 (catkin_package)
-- Configuring incomplete, errors occurred!
See also "/root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeOutput.log".
See also "/root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeError.log".
Failed <<< catkin [0.82s, exited with code 1]
log file:
/usr/bin/ld: src.c:(.text+0x39): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x45): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x56): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_210d5.dir/build.make:107: cmTC_210d5] Error 1
gmake[1]: Leaving directory '/root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:141: cmTC_210d5/fast] Error 2
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeTmp
Source file was:
#include <pthread.h>
void* test_func(void* data)
{
return data;
}
int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_cancel(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);
return 0;
}
Run Build Command(s):/usr/bin/gmake cmTC_d2cba/fast && /usr/bin/gmake -f CMakeFiles/cmTC_d2cba.dir/build.make CMakeFiles/cmTC_d2cba.dir/build
gmake[1]: Entering directory '/root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d2cba.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_d2cba.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTC_d2cba
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d2cba.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_d2cba.dir/CheckFunctionExists.c.o -o cmTC_d2cba -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_d2cba.dir/build.make:107: cmTC_d2cba] Error 1
gmake[1]: Leaving directory '/root/ros_catkin_ws/build/catkin/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:141: cmTC_d2cba/fast] Error 2
Is this a known issue? Is there a work around for thepthreads
? I also tried with -DBUILD_SHARED_LIBS=OFF
no difference.
Edit: after adding setuptools and pytest-cov here are the errors:
Failed <<< cyclonedds [0.56s, exited with code 1]
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /root/ros2_dashing/build/cyclonedds/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake cmTC_473c5/fast && /usr/bin/gmake -f CMakeFiles ...
The
pthreads
issue could be a red herring.I'd first solve this:
you appear to have Anaconda installed.
Have you made sure
pip
(invoked viarosdep
, but also manually) has installed the dependencies ROS needs for that specific interpreter, instead of your system provided one?If it hasn't, you basically haven't installed the dependencies.
Updated original post with similar errors even after installing setuptools and pytest-cov
I recently built ROS 2 Foxy on Fedora 32. It looks like you are trying to install ROS 2 Dashing that was released few years ago and was targeting Fedora 30 so maybe that's why you're facing more problems.
What I did to compile Foxy is:
python3-pep8
bypython3-pycodestyle
in the list of packages to installcolcon build --symlink-install
successfullyThanks several packages installed now, but I get a different error updated in the original post. What is
Failed <<< cyclonedds
Thanks @marguedas, now getting different errors, I also tried setting
-DBUILD_IDLC=OFF
incyclonedds/colcon.pkg
per this suggestion, now gettingImportError: cannot import name 'Interpreter' from 'em' (/usr/local/lib/python3.8/site-packages/em/__init__.py)
Any more suggestions?
You might have the Python package
em
installed which has the same namespace asempy
which is the packages needed bycolcon
as well as ROS 2. You need to uninstallem
and make sureempy
is installed. See https://github.com/colcon/colcon-core... for an improved error message in the future.Thanks @dirk-thomas, that was an issue but now it's all of these
undefined reference
errors, see the bottom of the original post (click 'more'). Since we have Anaconda Python and Fedora Python, I believe there could be a conflict. I tried upgrading Anaconda Python to 3.8, still same errors. I also tried using -DPYTHON_EXECUTABLE=/usr/local/bin/anaconda3/envs/python38/bin/python -DPYTHON_INCLUDE_DIR=/usr/local/bin/anaconda3/envs/python38/include/python3.8
as well as: