16

Is there a repository containing packages for old versions of gcc, for the latest Ubuntu. I want to install gcc3 alongside gcc 4, for programs that need gcc3 specifically.

8 Answers 8

17

You can use debian snapshots. Add the following lines to /etc/apt/sources.list

deb     http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb-src http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb     http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main
deb-src http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main

Now do

$ apt-get update
$ apt-get install g++-3.4

And you're set!

This works for many other old packages, make sure you select the correct timestamp, look for the correct one at snapshots.debian website.

7
  • I get this error after installing and trying to compile a program. Can you help me with this?
    – Phani
    Nov 8, 2014 at 4:11
  • @Phani not sure. Did you install all g++-3.4's dependencies? Nov 9, 2014 at 9:24
  • How do I do that? I installed build-essential using apt-get.
    – Phani
    Nov 14, 2014 at 23:09
  • Add the debian snapshot repository. You might want to check out a tutorial how to add repositories to debian. Nov 16, 2014 at 9:37
  • What happened after you followed the steps in the answer? Nov 16, 2014 at 9:37
14

Or alternatively to the Debian snapshots Elazar posted in his answer, you can use the Ubuntu package repositories for the older Ubuntu releases: http://packages.ubuntu.com

Add them to the /etc/apt/sources.list as Elazar already described:

deb     http://archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy universe

The Hardy Universe repository is the one that contains gcc-3.4.

6

You can add gcc-4.4 (or any version between 4.4 and 8) on Ubuntu 16.04 via the (Toolchain test builds PPA)

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install gcc-4.4

As an aside, if you need to emulate gcc-4.4 on RH6, build your target program with

make CC="gcc-4.4 -U_FORTIFY_SOURCE"
1
  • 1
    No, this doesn't work on modern ubuntu, apt can't find any new gcc versions, other then those available before.
    – stiv
    Feb 12, 2020 at 17:00
3

For 4.2.3 I had to add

deb http://security.ubuntu.com/ubuntu hardy-security main

to my /etc/apt/sources.list

Reference1, Reference2

3

For GCC 3.4 the correct source url is as below, since the old ones are moved into old-releases.ubuntu.com. Thanks to @Ignitor for the main pointer

edit

/etc/apt/sources.list

for breezy, dapper, edgy, feisty, gutsy, hardy etc

    deb     http://old-releases.ubuntu.com/ubuntu/ hardy universe
    deb-src http://old-releases.ubuntu.com/ubuntu/ hardy universe

from xenial

    apt update
    apt install gcc-3.4
2

gcc-3.3 is available in all current stable releases (In lucid, it is available in lucid-backports)

List of binaries available per release

You can see the above list with the following commands:

Source package list:

rmadison gcc-3.3

Source and binary list:

rmadison gcc-3.3 -S
0

Here is how to install the old GCC versions on Bionic (18.04).

For GCC 4.4 and 4.6:

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo apt install gcc-4.4 gcc-4.6

For GCC 4.7 and 4.9:

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo apt install gcc-4.7 gcc-4.9

And GCC 4.8 is already available:

sudo apt install gcc-4.8
-1

On Ubuntu 18.04, I did:

sudo apt install gcc-opt

to install gcc-3.3, gcc-3.4, and gcc-4.0

https://launchpad.net/ubuntu/+source/gcc-opt

1
  • This package only installs symlinks named gcc-3.3, gcc-3.4, and gcc-4.0. Jun 14, 2020 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.