Run the following in the terminal:
Install the gcc-7 packages:
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y
Set it up so the symbolic links gcc
, g++
point to the newer version:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --config gcc
gcc --version
g++ --version
# This one if you want the **all** toolchain programs (with the triplet names) to also point to gcc-7.
# For example, this is needed if building Debian packages.
# If you are already are root (e.g. inside a docker image), remove the "sudo" below.
ls -la /usr/bin/ | grep -oP "[\S]*(gcc|g\+\+)(-[a-z]+)*[\s]" | xargs sudo bash -c 'for link in ${@:1}; do ln -s -f "/usr/bin/${link}-${0}" "/usr/bin/${link}"; done' 7
Thanks for all of your answers. I have tried to install gcc-7.3 with the following commands. But I still get gcc 7.4.0. Can you provide a method only to install gcc 7.3.0?
$ sudo add-apt-repository ppa:jonathonf/gcc-7.3
$ sudo apt-get update
$ sudo apt-get install gcc-7 g++-7
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
After completion of the installation, I input the command of gcc --version and get the version of gcc 7.4.0.
Please see the message as follows
gcc ubuntu (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
............................................................................
I have Nvidia GeForce RTX 2060 which driver not supports gcc 7.4.0 but gcc 7.3.0. Please help me figure out the issue.
Note:
I also used the following commands to get gcc 7.4.0 rather than 7.3.0. So it is problem to install gcc 7.3.0.
$ sudo apt install build-essential
or
$ sudo apt install gcc
Thanks in advance,
Mike