Monday, March 26, 2018

Installing older version of GCC in Debian

I was compiling caffe today, and found that CUDA requires GCC version of <= 5. I have no other options but to install a older version of GCC on my Debian rig.

However, directly apt-get in result the following error:

Package gcc-4.9 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-4.9' has no installation candidate


To install older GCC (in this case GCC-4.9) on my Debian 9, I need to do add the ubuntu-toolchain test repository:
sudo vi /etc/apt/sources.list
Add the following lines:
deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
Note that I used xenial because gcc-4.9 is available on xenial:
https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Notice that gcc-4.9 is only available on 16.04, 14.04.1, and 12.04, I have chosen the latest one (16.04), which is xenial:


Now, I can install gcc-4.9 successfully:

sudo apt-get install gcc-4.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libxnvctrl0 nvidia-settings
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  gcc-4.9-multilib gcc-4.9-doc gcc-4.9-locales libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan1-dbg
  liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libquadmath0-dbg
The following NEW packages will be installed:
  gcc-4.9
0 upgraded, 1 newly installed, 0 to remove and 218 not upgraded.
Need to get 0 B/5,684 kB of archives.
After this operation, 18.4 MB of additional disk space will be used.
Selecting previously unselected package gcc-4.9.
(Reading database ... 235901 files and directories currently installed.)
Preparing to unpack .../gcc-4.9_4.9.4-2ubuntu1~16.04_amd64.deb ...
Unpacking gcc-4.9 (4.9.4-2ubuntu1~16.04) ...
Setting up gcc-4.9 (4.9.4-2ubuntu1~16.04) ...
Processing triggers for man-db (2.7.6.1-2) ...
gcc-4.9 --version
gcc-4.9 (Ubuntu 4.9.4-2ubuntu1~16.04) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 comment: