By default my system uses gcc 5.4.0 in ubuntu 16.04 to run a specific program l need to switch to gcc 4.8.
My question is the following :
How can l switch to gcc 4.8 before running the program and come back to gcc 4.8.4 once l've finished. The program l have to run is in python :
# what to do befor running the program
# python3.6 main.py
# how to come back to the gcc version by default
Here are the differents gcc version l have :
dpkg -l | grep gcc | awk '{print $2}'
gcc
gcc-4.8
gcc-4.8-base:amd64
gcc-4.9
gcc-4.9-base:amd64
gcc-5
gcc-5-base:amd64
gcc-6-base:amd64
gir1.2-packagekitglib-1.0
lib32gcc1
libcaca0:amd64
libgcc-4.8-dev:amd64
libgcc-4.9-dev:amd64
libgcc-5-dev:amd64
libgcc1:amd64
libpackagekit-glib2-16:amd64
libunity-action-qt1:amd64
libwebrtc-audio-processing-0:amd64
qtchooser
qtdeclarative5-unity-action-plugin:amd64
EDIT1 Is it correct if l do the following as suggested in https://askubuntu.com/questions/26498/choose-gcc-and-g-version
Have l set that correclty ?
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 30
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 40
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 40
sudo update-alternatives --set c++ /usr/bin/g++
But l stack at the last command :
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
do l need to set that as :
sudo update-alternatives --config gcc-4.8
sudo update-alternatives --config g++-4.8
and when l want to come back to gcc 5 l set it to :
sudo update-alternatives --config gcc-5
sudo update-alternatives --config g++-5
Am l right ?
EDIT2 l need to run python3.6 with gcc 4.8.4 . The default gcc version of python3.6 is 4.4.7
root@ahmed-OMEN-by-HP-Laptop:~# python3.6
Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
How can l change that ?
gcc
is a compiler - it should have no effect on your programs at runtime. So, for example, when you seeGCC 4.4.7
in thepython3.6
version information, it's just telling you what compiler the python3.6 executable was built with - you can't change that without recompiling python3.6. – steeldriver Apr 27 '17 at 15:42