Exercise 4.3 - cmake error

Hi, so I was doing the ROS Basics course with no problem, until I arrived at exercise 4.3 of making the turtlebot avoid the wall. However I had a problem compiling the project, since catkin_make is giving me an error. I tried searching on the internet and in this forum with no luck. I did manage to build and compile with catkin build and it ran fine, but the bot correcting the quiz uses catkin_make, so it fails there.

Here is last lines of the console output:

- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/noetic/share/xmlrpcpp
- noetic/noetic/share/xmlrpcpp
- noetic/share/xmlrpcpp
- share/xmlrpcpp
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/home/user/catkin_ws/build/catkin_generated/env_cached.sh
  "/usr/bin/python3" "/usr/lib/python3/dist-packages/em.py" "--raw-errors"
  "-F" "/home/user/catkin_ws/build/catkin_generated/order_packages.py" "-o"
  "/home/user/catkin_ws/build/catkin_generated/order_packages.cmake"
  "/opt/ros/noetic/share/catkin/cmake/em/order_packages.cmake.em") returned
  error code 1
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/em_expand.cmake:25 (safe_execute_process)
  /opt/ros/noetic/share/catkin/cmake/catkin_workspace.cmake:35 (em_expand)
  CMakeLists.txt:69 (catkin_workspace)


-- Configuring incomplete, errors occurred!
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

Here is CMakeError.log:

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/user/catkin_ws/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_5092c/fast && /usr/bin/make -f CMakeFiles/cmTC_5092c.dir/build.make CMakeFiles/cmTC_5092c.dir/build
make[1]: Entering directory '/home/user/catkin_ws/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_5092c.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_5092c.dir/src.c.o   -c /home/user/catkin_ws/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_5092c
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5092c.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD    -rdynamic CMakeFiles/cmTC_5092c.dir/src.c.o  -o cmTC_5092c 
/usr/bin/ld: CMakeFiles/cmTC_5092c.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_5092c.dir/build.make:87: cmTC_5092c] Error 1
make[1]: Leaving directory '/home/user/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_5092c/fast] Error 2


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_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/user/catkin_ws/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_95b04/fast && /usr/bin/make -f CMakeFiles/cmTC_95b04.dir/build.make CMakeFiles/cmTC_95b04.dir/build
make[1]: Entering directory '/home/user/catkin_ws/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_95b04.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_95b04.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_95b04
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_95b04.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_95b04.dir/CheckFunctionExists.c.o  -o cmTC_95b04  -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_95b04.dir/build.make:87: cmTC_95b04] Error 1
make[1]: Leaving directory '/home/user/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_95b04/fast] Error 2

Thanks for the help in advance,

João Pinhal

Please try:

cd ~/catkin_ws
rm -rf build/ devel/
catkin_make
source devel/setup.bash

I’m getting the same error too. Even though I did what you said, there was no change.

– Configuring incomplete, errors occurred!
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeError.log”.
Invoking “cmake” failed
user:~/catkin_ws$ cd ~/catkin_ws
user:~/catkin_ws$ rm -rf build/ devel/
user:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install

Running command: “cmake /home/user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install -G Unix Makefiles” in “/home/user/catkin_ws/build”

– The C compiler identification is GNU 9.3.0
– The CXX compiler identification is GNU 9.3.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
– Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
– This workspace overlays: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.8.5”, minimum required is “3”)
– Using PYTHON_EXECUTABLE: /usr/bin/python3
– Using Debian Python package layout
– Found PY_em: /usr/lib/python3/dist-packages/em.py
– Using empy: /usr/lib/python3/dist-packages/em.py
– Using CATKIN_ENABLE_TESTING: ON
– Call enable_testing()
– Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
– Forcing gtest/gmock from source, though one was otherwise available.
– Found gtest sources under ‘/usr/src/googletest’: gtests will be built
– Found gmock sources under ‘/usr/src/googletest’: gmock will be built
– Found PythonInterp: /usr/bin/python3 (found version “3.8.5”)
– Found Threads: TRUE
– Using Python nosetests: /usr/bin/nosetests3
– catkin 0.8.9
– BUILD_SHARED_LIBS is on
– BUILD_SHARED_LIBS is on
– ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
– ~~ traversing 11 packages in topological order:
– ~~ - exercise_31
– ~~ - exercise_86
– ~~ - exercise_913
– ~~ - my_custom_srv_msg_pkg
– ~~ - my_examples_pkg
– ~~ - my_package
– ~~ - my_python_class
– ~~ - services_quiz
– ~~ - actions_quiz
– ~~ - topics_quiz
– ~~ - unit_5_services
– ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
– +++ processing catkin package: ‘exercise_31’
– ==> add_subdirectory(exercise_31)
– +++ processing catkin package: ‘exercise_86’
– ==> add_subdirectory(exercise_86)
– +++ processing catkin package: ‘exercise_913’
– ==> add_subdirectory(exercise_913)
– +++ processing catkin package: ‘my_custom_srv_msg_pkg’
– ==> add_subdirectory(my_custom_srv_msg_pkg)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
– my_custom_srv_msg_pkg: 0 messages, 1 services
– +++ processing catkin package: ‘my_examples_pkg’
– ==> add_subdirectory(my_examples_pkg)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
– my_examples_pkg: 1 messages, 0 services
– +++ processing catkin package: ‘my_package’
– ==> add_subdirectory(my_package)
– +++ processing catkin package: ‘my_python_class’
– ==> add_subdirectory(my_python_class)
– +++ processing catkin package: ‘services_quiz’
– ==> add_subdirectory(services_quiz)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
– services_quiz: 0 messages, 1 services
– +++ processing catkin package: ‘actions_quiz’
– ==> add_subdirectory(actions_quiz)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
– Generating .msg files for action actions_quiz/CustomActionMsg /home/user/catkin_ws/src/actions_quiz/action/CustomActionMsg.action
Generating for action CustomActionMsg
– actions_quiz: 7 messages, 0 services
– +++ processing catkin package: ‘topics_quiz’
– ==> add_subdirectory(topics_quiz)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
– +++ processing catkin package: ‘unit_5_services’
– ==> add_subdirectory(unit_5_services)
– Could NOT find iri_wam_reproduce_trajectory (missing: iri_wam_reproduce_trajectory_DIR)
– Could not find the required component ‘iri_wam_reproduce_trajectory’. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by
“iri_wam_reproduce_trajectory” with any of the following names:

iri_wam_reproduce_trajectoryConfig.cmake
iri_wam_reproduce_trajectory-config.cmake

Add the installation prefix of “iri_wam_reproduce_trajectory” to
CMAKE_PREFIX_PATH or set “iri_wam_reproduce_trajectory_DIR” to a directory
containing one of the above files. If “iri_wam_reproduce_trajectory”
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
unit_5_services/CMakeLists.txt:10 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeError.log”.
Invoking “cmake” failed

Now the error you posted is different.

Please remove every reference to iri_wam_reproduce_trajectory in the package unit_5_services. Check CMakeLists.txt and package.xml.

PS: when you have this kind of error, please carefully read the error messages. The hint above is from the error message you shared.

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.