Ask Your Question

colcon build --symlink-install can't find '__main__' module; ld: cannot find -lpthreads

asked 2020-08-14 22:50:03 -0600

RobbieTheK gravatar image

updated 2020-08-15 20:53:09 -0600

On Fedora 32, ROS 10.1, following these instructions, running colcon build --symlink-install errors out with the below:

/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):

  "/usr/local/bin/anaconda3/lib/python3.7/site-packages/em" "--raw-errors"
  "-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_join(thread, NULL);
  pthread_atfork(NULL, NULL, 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 ...
edit retag flag offensive close merge delete


The pthreads issue could be a red herring.

I'd first solve this:

/usr/local/bin/anaconda3/bin/python: can't find '__main__' module in '/usr/local/bin/anaconda3/lib/python3.7/site-packages/em'

you appear to have Anaconda installed.

Have you made sure pip (invoked via rosdep, 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.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-15 03:58:18 -0600 )edit

Updated original post with similar errors even after installing setuptools and pytest-cov

RobbieTheK gravatar image RobbieTheK  ( 2020-08-15 08:58:10 -0600 )edit

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:

marguedas gravatar image marguedas  ( 2020-08-15 10:16:32 -0600 )edit

Thanks several packages installed now, but I get a different error updated in the original post. What is Failed <<< cyclonedds

RobbieTheK gravatar image RobbieTheK  ( 2020-08-15 10:53:33 -0600 )edit

Thanks @marguedas, now getting different errors, I also tried setting -DBUILD_IDLC=OFF in cyclonedds/colcon.pkg per this suggestion, now getting ImportError: cannot import name 'Interpreter' from 'em' (/usr/local/lib/python3.8/site-packages/em/

RobbieTheK gravatar image RobbieTheK  ( 2020-08-15 19:13:30 -0600 )edit

Any more suggestions?

collect2: error: ld returned 1 exit status
/usr/bin/ld: /usr/lib64/ undefined reference to `EVP_KDF_ctrl@OPENSSL_1_1_1b'
/usr/bin/ld: /usr/lib64/ undefined reference to `SSLv3_client_method@OPENSSL_1_1_0'
/usr/bin/ld: /usr/lib64/ undefined reference to `EVP_KDF_derive@OPENSSL_1_1_1b'
gmake[2]: *** [CMakeFiles/grid_test_target.dir/build.make:130: grid_test_target] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:451: CMakeFiles/grid_test_target.dir/all] Error 2
collect2: error: ld returned 1 exit status
/usr/bin/ld: /usr/lib64/ undefined reference to `EVP_KDF_CTX_free@OPENSSL_1_1_1b'
gmake[2]: *** [CMakeFiles/movable_text_test_target.dir/build.make:131: movable_text_test_target] Error 1
Failed   <<< rviz_rendering
RobbieTheK gravatar image RobbieTheK  ( 2020-08-15 20:03:10 -0600 )edit

ImportError: cannot import name 'Interpreter' from 'em'

You might have the Python package em installed which has the same namespace as empy which is the packages needed by colcon as well as ROS 2. You need to uninstall em and make sure empyis installed. See for an improved error message in the future.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-08-17 13:21:09 -0600 )edit

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:

RobbieTheK gravatar image RobbieTheK  ( 2020-08-17 13:31:08 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-08-18 11:01:27 -0600

RobbieTheK gravatar image

updated 2020-09-04 12:02:14 -0600

Finally I got it going. Here are the work-arounds needed:

-Add the stanza from this repo to ros2.repos.

-Change the option -DBUILD_IDLC=OFF in cyclonedds/colcon.pkg per this suggestion

-Updated $PATH so /usr/bin was first to ensure Fedora's Python 3.8 was used.

Now trying to determine how to install it so multiple users can use the ROS 2 commands. Do the binaries still need to be installed? Will that work on Fedora? They all seem customized for Debian/Ubuntu.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-08-14 22:50:03 -0600

Seen: 465 times

Last updated: Sep 04 '20