Tag Archives: catkin_make error

[Solved] catkin_make Error: Invoking “make -j12 -l12“ failed

While studying the official ROS tutorial Writing a Simple Publisher and Subscriber (C++), the following error occurred when running catkin_make:

Base path: /home/free/catkin_ws
Source space: /home/free/catkin_ws/src
Build space: /home/free/catkin_ws/build
Devel space: /home/free/catkin_ws/devel
Install space: /home/free/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/free/catkin_ws/build"
####
####
#### Running command: "make -j12 -l12" in "/home/free/catkin_ws/build"
####
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_Num
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_AddTwoInts
[ 58%] Built target beginner_tutorials_generate_messages_py
[ 64%] Built target beginner_tutorials_generate_messages_eus
[ 58%] Built target beginner_tutorials_generate_messages_lisp
[ 58%] Built target beginner_tutorials_generate_messages_cpp
[ 76%] Built target beginner_tutorials_generate_messages_nodejs
[ 76%] Built target beginner_tutorials_generate_messages
[ 82%] Linking CXX executable /home/free/catkin_ws/devel/lib/beginner_tutorials/talker
[ 88%] Linking CXX executable /home/free/catkin_ws/devel/lib/beginner_tutorials/listener
/usr/bin/ld: CMakeFiles/listener.dir/src/listener.cpp.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: Final link failure: output non-representable links
collect2: error: ld returned 1 exit status
beginner_tutorials/CMakeFiles/listener.dir/build.make:112: recipe for target '/home/free/catkin_ws/devel/lib/beginner_tutorials/listener' failed
make[2]: *** [/home/free/catkin_ws/devel/lib/beginner_tutorials/listener] Error 1
CMakeFiles/Makefile2:1344: recipe for target 'beginner_tutorials/CMakeFiles/listener.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/listener.dir/all] Error 2
make[1]: *** Waiting for unfinished tasks....
/usr/bin/ld: CMakeFiles/talker.dir/src/talker.cpp.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: Final link failure: output non-representable links
collect2: error: ld returned 1 exit status
beginner_tutorials/CMakeFiles/talker.dir/build.make:112: recipe for target '/home/free/catkin_ws/devel/lib/beginner_tutorials/talker' failed
make[2]: *** [/home/free/catkin_ws/devel/lib/beginner_tutorials/talker] Error 1
CMakeFiles/Makefile2:1381: recipe for target 'beginner_tutorials/CMakeFiles/talker.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/talker.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j12 -l12" failed

After looking for the reason for a long time, I finally found that the final error was due to the wrong version of GCC and G + +. After changing GCC and g++ 5.5.0, I successfully compiled

Process for installing GCC and g++ version 5.5.0:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update 
sudo apt-get install gcc-5
sudo apt-get install g++-5

Change GCC and g++ versions

cd /usr/bin 
sudo rm gcc 
sudo ln -s gcc-5 gcc 
sudo rm g++ 
sudo ln -s g++-5 g++

Finally, check whether the modification is successful

gcc --version
g++ --version

Recompile:

catkin_make clean   #Clear the front compile
catkin_make 

[Solved] catkin_make Error: pkg_resources.DistributionNotFound: pyparsing

A new workspace is created and catkin_make gives the following error:

Base path: /home/caohaojie/ros_ws
Source space: /home/caohaojie/ros_ws/src
Build space: /home/caohaojie/ros_ws/build
Devel space: /home/caohaojie/ros_ws/devel
Install space: /home/caohaojie/ros_ws/install
####
#### Running command: "cmake /home/caohaojie/ros_ws/src -DCATKIN_DEVEL_PREFIX=/home/caohaojie/ros_ws/devel -DCMAKE_INSTALL_PREFIX=/home/caohaojie/ros_ws/install -G Unix Makefiles" in "/home/caohaojie/ros_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
CMake Error at CMakeLists.txt:22 (message):
  Search for 'catkin' in workspace failed (catkin_find_pkg catkin
  /home/caohaojie/ros_ws/src): Traceback (most recent call last):
    File "/home/caohaojie/.local/bin/catkin_find_pkg", line 5, in <module>
      from pkg_resources import load_entry_point
    File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2603, in <module>
    File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 666, in require
    File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 565, in resolve
  pkg_resources.DistributionNotFound: pyparsing

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

 

Solution:
Downgrade the version of catkin-pkg
$pip3 install catkin-pkg==0.4.16