How to cleanly install gcc-4.9 and g++-4.9 to Ubuntu 18.04 Bionic Beaver?

1k views Asked by At

I couldn't find them even after adding ppa:ubuntu-toolchain-r/test repository to apt. I'd like to use package manager.

1

There are 1 answers

0
Janne On

I ended up with a rather undirty hack (way less dirty, than of what you see in ubuntu land):

  1. Temporarily, change sources.list from bionic to xential
  2. apt update
  3. aptitude install gcc-4.9 g++-4.9
  4. change sources.list back to bionic, apt update
sudo -i
apt update; aptitude full-upgrade
cd /etc/apt
sed 's/bionic/xential/g' < sources.list > sources.list-xential
mv -v sources.list{,-bionic}
ln -sv sources.list-xential sources.list
apt update
aptitude -y install gcc-4.9 g++-4.9
ln -svf sources.list-bionic sources.list
apt update

This way you can use package manager and the official packages. I didn't break anything, as apt doesn't downgrade without need.