Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22024

How to use a newer version of gcc on ubuntu?

$
0
0

I am running ubuntu 18.04 and I currently have:

(tensorflow_p36) ubuntu@user:~$ gcc --version
gcc (GCC) 4.8.5

(tensorflow_p36) ubuntu@user:~$ gcc-8 --version
gcc-8 (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

(tensorflow_p36) ubuntu@user:~$ which gcc
/home/ubuntu/anaconda3/envs/tensorflow_p36/bin/gcc

I am trying to use the latest gcc-8 as show here. However when I run

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8

I get the following error:

update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative

When I try:

(tensorflow_p36) ubuntu@user:~$ sudo update-alternatives --config gcc

I get another error:

update-alternatives: error: no alternatives for gcc

How is it that I do not have alternative for gcc? Any suggestions on how I can resolve this error and configure gcc-8 to be the default gcc installation would be appreciated.


Running which gcc from outside the conda environment does not return anything:

ubuntu@user:~$ which gcc
ubuntu@user:~$

but

ubuntu@user:~$ gcc-8 --version
gcc-8 (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

Update. I'm trying the following as per the helpful suggestion below, but still to no avail.

(tensorflow_p36) ubuntu@user:~$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 40
(tensorflow_p36) ubuntu@user:~$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 60
(tensorflow_p36) ubuntu@user:~$ sudo update-alternatives --config g++
There are 3 choices for the alternative g++ (providing /usr/bin/g++).

  Selection    Path                             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/x86_64-linux-gnu-g++-7   100       auto mode
  1            /usr/bin/g++-4.8                  60        manual mode
  2            /usr/bin/g++-8                    40        manual mode
  3            /usr/bin/x86_64-linux-gnu-g++-7   100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/g++-8 to provide /usr/bin/g++ (g++) in manual mode

So far so good, but when I test the g++ version, it's still the same!

~$ g++ --version
g++ (GCC) 4.8.5

Viewing all articles
Browse latest Browse all 22024

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>