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
Read More:
- C++ Error: Invoking “make -j2 -l2“ failed [How to Solve]
- [Solved] Install nginx make & make install error report record
- [PX4 Bug] make px4_sitl gazebo Error: CMake Error: The following variables are used in this project
- [Solved] graphviz Error: failed to execute [‘dot’, ‘-Tsvg’], make sure the Graphviz executables are on your systems’ PATH
- React-native Error: Make sure you have the Android development environment set up [Solved]
- [Solved] RK3399 Compile UBOOT Error: No rule to make target , needed by
- [Solved] MIT cheetah make error: ‘ioctl’ was not declared in this scope
- [Solved] VScode Error: find_package(catkin) failed
- How to Solve Error: Error running ‘__rvm_make -j8‘ (Mac M1 BigSur)
- Execute an error under pytest cmd make sure your test modules/packages have valid Python names.
- buildroot SIGSTKSZ Error: make[5]: *** [Makefile:1915: c-stack.o] Error 1
- [Solved] java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest()…
- Ubutnu Qt Unable to start process Error: “make“ -f ‘ /usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit sta
- [Solved] error: taking address of temporary array av_make_error_string((char[AV_ERROR_MAX_STRING_SI…
- Error in invoking target [How to Solve]
- Node.js operation mysql error Cannot enqueue Handshake after invoking quit
- [Solved] Oracle 18C RAC Install Error: Error in invoking target ‘irman ioracle idrdactl idrdalsnr idrdaproc‘ of makefile
- SpringBoot uses MyBatis error: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)
- ORB-SLAM3 Compile Error: recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o‘ failed
- Eclipse Godson Error: Makefile:recipe for target ‘clean‘ failed