install gcc7 in ubuntu22

Asked by daren nofl

root@click:/home/click# sudo add-apt-repository ppa:ubuntu-toolchain-r/test
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/ jammy main'
Description:
Toolchain test builds; see https://wiki.ubuntu.com/ToolChain

More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ubuntu-toolchain-r-ubuntu-test.gpg with fingerprint 60C317803A41BA51845E371A1E9377A2BA9EF27F
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Get:4 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy InRelease [23.8 kB]
Hit:5 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:6 https://dl.winehq.org/wine-builds/ubuntu jammy InRelease
Hit:7 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [11.4 kB]
Get:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy/main amd64 Packages [504 B]
Get:10 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy/main Translation-en [308 B]
Fetched 146 kB in 4s (33.8 kB/s)
Reading package lists... Done
root@click:/home/click# sudo apt install gcc-7 g++-7 gcc-8 g++-8 gcc-9 g++-9
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package g++-8 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

Package g++-7 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

Package gcc-8 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

Package gcc-7 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 'gcc-7' has no installation candidate
E: Package 'g++-7' has no installation candidate
E: Package 'gcc-8' has no installation candidate
E: Package 'g++-8' has no installation candidate
root@click:/home/click# sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
update-alternatives: error: alternative path /usr/bin/gcc-7 doesn't exist
root@click:/home/click# sudo update-alternatives --config gcc
update-alternatives: error: no alternatives for gcc
root@click:/home/click#

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said (last edit ):
#1

Why do you want to install obsolete software?

gcc versions 7 and 8 have been removed from the official repositories for Ubuntu jammy on purpose.

see also
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923982
and
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954831

Why can't you use gcc-9, gcc-10, gcc-11 or gcc-12 (and the same for g++-*)

And for the question why a certain version of a specific software package is not available in a PPA:
For this you have to ask the provider of the PPA listed on the PPA page.

Revision history for this message
Manfred Hampl (m-hampl) said :
#2

Another remark:

You refer to https://wiki.ubuntu.com/ToolChain

Read the paragraph
GCC
GCC is packaged by major/minor version. The source packages are called gcc-4.8, gcc-4.9, etc. Some language frontends are built from a separate "source" package to reduce the build and test time of these packages (gnat-4.9).
The default (recommended) GCC version is packaged as the gcc-defaults package, building binary packages gcc, g++, gfortran, etc.

The default for gcc on Ubuntu jammy is gcc-11

Revision history for this message
daren nofl (daren-2022) said :
#3

because StaMPS has to be compiled with gcc-7 (gcc-9 was installed in my case and used for the compilation of StaMPS which led to incorrectly compiled scripts)

Revision history for this message
Manfred Hampl (m-hampl) said :
#4

I do not know which "StaMPS" you are talking about (maybe https://github.com/dbekaert/StaMPS ), but if that software cannot be built with current gcc versions, then this is a problem of that software and not something that should be solved in Ubuntu by re-introducing obsolete software versions.

Can you help with this problem?

Provide an answer of your own, or ask daren nofl for more information if necessary.

To post a message you must log in.