Linker goes bananas on Ubuntu 16.04 + ROS Kinetic + gcc 4.8
So, due to some peculiarities of my project I am in need of compiling everything with compiler suite version 4.8 instead of the default compiler version that comes with Ubuntu 16.04 ( 5.4 ). I used update-alternatives to set the compiler version (gcc, g++ etc...) to 4.8. But when I execute catkin_make, the linker starts complaining about not being able to find symbols like ros::NodeHandle, ros::init, etc...
Everything compiles and links just fine if I use the default compiler version (but I really need to compile with version 4.8).
To make sure that this is not due to the peculiarities of my project and development environment I have installed a fresh Ubuntu 16.04 + ROS Kinetic on a virtual machine, created a workspace containing the roscpp_tutorials and made sure that the following command works out of the box:
catkin_make -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -j1
Which compiles everthing and works and its all smiles and sunshine.
Then I install the compiler version 4.8 as follows:
sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
sudo update-alternatives --set c++ /usr/bin/g++
I make sure to remove the directories build and devel from my catkin workspace:
secret_agent@CIA:~/top_secret/catkin_ws$ rm -rf build devel
And compile again:
secret_agent@CIA:~/top_secret/catkin_ws$ catkin_make -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -j1
Base path: /home/secret_agent/top_secret/catkin_ws
Source space: /home/secret_agent/top_secret/catkin_ws/src
Build space: /home/secret_agent/top_secret/catkin_ws/build
Devel space: /home/secret_agent/top_secret/catkin_ws/devel
Install space: /home/secret_agent/top_secret/catkin_ws/install
####
#### Running command: "cmake /home/secret_agent/top_secret/catkin_ws/src -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCATKIN_DEVEL_PREFIX=/home/secret_agent/top_secret/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/secret_agent/top_secret/catkin_ws/install -G Unix Makefiles" in "/home/secret_agent/top_secret/catkin_ws/build"
####
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- 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/secret_agent/top_secret/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/secret_agent/top_secret/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/secret_agent/top_secret/catkin_ws/devel;/opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/secret_agent/top_secret/catkin_ws ...