• Uncategorized

About linux : Issue-create-ROS-workspace-with-catkinmake-Invoking-cmake-failed

Question Detail

I’ve been trying to create a workspace for ROS as according to ROS tutorial 1:
http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment

Im running Ubuntu 20.04.3 LTS

However I continuously get an error when trying to make the catkin workspace ending in an error with cmake.

The full log I get is below:

omega@omega:~$ cd catkin_ws/
omega@omega:~/catkin_ws$ ls
build  devel  src
omega@omega:~/catkin_ws$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
Base path: /home/omega/catkin_ws
Source space: /home/omega/catkin_ws/src
Build space: /home/omega/catkin_ws/build
Devel space: /home/omega/catkin_ws/devel
Install space: /home/omega/catkin_ws/install
####
#### Running command: "cmake /home/omega/catkin_ws/src -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCATKIN_DEVEL_PREFIX=/home/omega/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/omega/catkin_ws/install -G Unix Makefiles" in "/home/omega/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/omega/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/omega/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.10") 
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
/home/omega/catkin_ws/devel/env.sh: 31: /tmp/setup.sh.pOmFyl3g0b: Syntax error: Unterminated quoted string
Traceback (most recent call last):
  File "/home/omega/catkin_ws/build/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/omega/catkin_ws/devel/env.sh')
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin/environment_cache.py", line 62, in generate_environment_script
    output = subprocess.check_output([env_script, sys.executable, '-c', python_code])
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/omega/catkin_ws/devel/env.sh', '/usr/bin/python3', '-c', 'import os; print(dict(os.environ))']' returned non-zero exit status 2.
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/home/omega/catkin_ws/build/catkin_generated/generate_cached_setup.py")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/all.cmake:208 (safe_execute_process)
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:61 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/omega/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/omega/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed
omega@omega:~/catkin_ws$ catkin_make
Base path: /home/omega/catkin_ws
Source space: /home/omega/catkin_ws/src
Build space: /home/omega/catkin_ws/build
Devel space: /home/omega/catkin_ws/devel
Install space: /home/omega/catkin_ws/install
####
#### Running command: "cmake /home/omega/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/omega/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/omega/catkin_ws/install -G Unix Makefiles" in "/home/omega/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/omega/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/omega/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.10") 
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
/home/omega/catkin_ws/devel/env.sh: 31: /tmp/setup.sh.nafnuJ2e0G: Syntax error: Unterminated quoted string
Traceback (most recent call last):
  File "/home/omega/catkin_ws/build/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/omega/catkin_ws/devel/env.sh')
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin/environment_cache.py", line 62, in generate_environment_script
    output = subprocess.check_output([env_script, sys.executable, '-c', python_code])
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/omega/catkin_ws/devel/env.sh', '/usr/bin/python3', '-c', 'import os; print(dict(os.environ))']' returned non-zero exit status 2.
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/home/omega/catkin_ws/build/catkin_generated/generate_cached_setup.py")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/all.cmake:208 (safe_execute_process)
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:61 (find_package)


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

I’m not sure what to adjust at this point.

Here are the contents to CMakeError.log

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

Run Build Command(s):/usr/bin/make cmTC_43f9e/fast && /usr/bin/make -f CMakeFiles/cmTC_43f9e.dir/build.make CMakeFiles/cmTC_43f9e.dir/build
make[1]: Entering directory '/home/omega/catkin_ws/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_43f9e.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_43f9e.dir/src.c.o   -c /home/omega/catkin_ws/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_43f9e
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_43f9e.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD    -rdynamic CMakeFiles/cmTC_43f9e.dir/src.c.o  -o cmTC_43f9e 
/usr/bin/ld: CMakeFiles/cmTC_43f9e.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_43f9e.dir/build.make:87: cmTC_43f9e] Error 1
make[1]: Leaving directory '/home/omega/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_43f9e/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/omega/catkin_ws/build/CMakeFiles/CMakeTmp

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

The contents of CMakeLists.txt is:

# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake

#Enable C++ 11
add_compile_options(-std=c++11)

cmake_minimum_required(VERSION 3.0.2)

project(Project)

set(CATKIN_TOPLEVEL TRUE)

# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
  RESULT_VARIABLE _res
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
  # searching fot catkin resulted in an error
  string(REPLACE ";" " " _cmd_str "${_cmd}")
  message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")
endif()

# include catkin from workspace or via find_package()
if(_res EQUAL 0)
  set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
  # include all.cmake without add_subdirectory to let it operate in same scope
  include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)
  add_subdirectory("${_out}")

else()
  # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
  # or CMAKE_PREFIX_PATH from the environment
  if(NOT DEFINED CMAKE_PREFIX_PATH)
    if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
      if(NOT WIN32)
        string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
      else()
        set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
      endif()
    endif()
  endif()

  # list of catkin workspaces
  set(catkin_search_path "")
  foreach(path ${CMAKE_PREFIX_PATH})
    if(EXISTS "${path}/.catkin")
      list(FIND catkin_search_path ${path} _index)
      if(_index EQUAL -1)
        list(APPEND catkin_search_path ${path})
      endif()
    endif()
  endforeach()

  # search for catkin in all workspaces
  set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
  find_package(catkin 
    QUIET
    NO_POLICY_SCOPE
    PATHS ${catkin_search_path}
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  unset(CATKIN_TOPLEVEL_FIND_PACKAGE)

  if(NOT catkin_FOUND)
    message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
  endif()
endif()

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.