Tested on Ubuntu 20.04:
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt update
sudo apt install g++-10
Answer from Vladimir Talybin on askubuntu.comI have a hard time installing gcc-10 package (with all c/c++ stuff) on my Debian Buster. I would line to download and install the package from this mirror: http://ftp.cz.debian.org/debian. The package is there at http://ftp.cz.debian.org/debian/pool/main/g/gcc-10/.
In debian, I added the following line to the /etc/apt/sources.list file:
deb http://ftp.cz.debian.org/debian buster main
Then I ran apt-get update with the following result:
Get:1 http://ftp.cz.debian.org/debian buster InRelease [121 kB] Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Hit:3 http://deb.debian.org/debian buster InRelease Get:4 http://deb.debian.org/debian buster-updates InRelease [51.9 kB] Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [272 kB] Get:7 http://ftp.cz.debian.org/debian buster/main amd64 Packages [7,907 kB] Hit:6 https://packagecloud.io/github/git-lfs/debian buster InRelease Fetched 8,417 kB in 7s (1,146 kB/s) Reading package lists... Done
But then, when I run apt-get install gcc-10, i get this:
Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package gcc-10
Is there anything I am missing or doing wrong?
Tested on Ubuntu 20.04:
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt update
sudo apt install g++-10
I replaced the version used in this article with mine and installed to /usr/loacl/bin instead.
Then I needed to update the gcc alternatives as shown here. I replaced this version with mine. I used /usr/local/bin/gcc-10.2.0/bin/gcc-10.2 to use the executable instead of the folder. It's currently working for me.
From a fresh start of debian:10:
Copyecho 'deb http://deb.debian.org/debian testing main' > /etc/apt/sources.list.d/testing.list
apt update
cat <<EOF > /etc/apt/preferences.d/pin
Package: *
Pin: release a=stable
Pin-Priority: 700
Package: *
Pin: release a=testing
Pin-Priority: 650
EOF
apt install -qq -y -t testing build-essential
yields:
Copy# g++ -v
gcc version 9.3.0 (Debian 9.3.0-11)
In my Dockerfile I did:
CopyFROM debian:latest AS env
...
RUN echo 'deb http://deb.debian.org/debian testing main' >> /etc/apt/sources.list
RUN apt update -y
RUN apt install -y gcc
note: I added these line after the install of build-essential so technically the container install the "default" gcc then it is updated by the one in the testing repo...
note2: Using RUN gcc --version I've got gcc (Debian 9.3.0-11) 9.3.0 :D