Instale gcc/g++ 6 no Ubuntu 21.04

Instale gcc/g++ 6 no Ubuntu 21.04

Estou tentando compilar o Cuda 10.2 e previsivelmente o gcc-10 não funcionará para compilá-lo. Ao usar o 20.04 era simples, adicionar repositório biônico, atualizar, instalar, atualizar alternativas. Usando o 21.04, não consigo fazer nada funcionar.

Eu tentei com repositórios xenial e biônico 'principal' e 'universo', o que gerou um erro sobre o PUBKEY. Peguei os PUBKEYs do servidor de chaves do Ubuntu e atualizei a lista de pacotes, sem erros.

sudo apt install g++-6

Package g++-6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'g++-6' has no installation candidate

fontes.lista ->

deb http://archive.ubuntu.com/ubuntu hirsute restricted main multiverse universe

deb http://archive.ubuntu.com/ubuntu hirsute-updates restricted main multiverse universe

deb http://archive.ubuntu.com/ubuntu hirsute-security restricted main multiverse universe

# gcc-6
deb [allow-insecure=yes] http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
#deb [allow-insecure=yes] http://dk.archive.ubuntu.com/ubuntu/ xenial main universe

Alguém sabe como posso conseguir isso usando o Ubuntu 21.04? Cada postagem que li diz para adicionar os repositórios biônicos ou xeniais, atualizar, instalar. Não tive sorte até agora.

Responder1

Peguei os pacotes (.deb) que precisava navegando nos repositórios do Ubuntuaqui.

Aqui está uma lista dos pacotes .deb que eu precisava para instalar manualmente o gcc/g++ 6. Instale na ordem da lista. Isso pressupõe que você tenha a maioria das ferramentas necessárias para compilar e esteja apenas procurando mudar as versões padrão do gcc.

sudo apt install ./libisl19_0.19-1_amd64.deb
sudo apt install ./gcc-6-base_6.4.0-17ubuntu1_amd64.deb
sudo apt install ./cpp-6_6.4.0-17ubuntu1_amd64.deb

# you can grab this next package from 21.04 repos, it handles a lot of the dependancies.
sudo apt install libgcc-6-dev

# Finally
sudo apt install ./gcc-6_6.4.0-17ubuntu1_amd64.deb

# GCC-6 is now installed, you can test by gcc-6 -v
baudneo@ZMES-test:~$ gcc-6 -v
gcc version 6.4.0 20180424 (Ubuntu 6.4.0-17ubuntu1)

# Now for G++ 6
sudo apt install ./libstdc++-6-dev_6.4.0-17ubuntu1_amd64.deb
sudo apt install ./g++-6_6.4.0-17ubuntu1_amd64.deb

# G++-6 is now installed! test by g++-6 -v
baudneo@ZMES-test:~$ g++-6 -v
gcc version 6.4.0 20180424 (Ubuntu 6.4.0-17ubuntu1)

# Now it is time to configure the system to use GCC G++ 6
# This assumes you do not have other versions of gcc and g++ installed for other projects

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 100
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 100
sudo update-alternatives --set c++ /usr/bin/g++
# When you want to revert these back to default gcc-10
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
sudo update-alternatives --set c++ /usr/bin/g++

informação relacionada