4

I am currently using Ubuntu 18.04, and I need gcc 4.8 for MATLAB. So I tried to install gcc-4.8 using

$ sudo apt-get install gcc-4.8
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_4.15.0-117.118_amd64.deb  404  Not Found [IP: 2403:8940:3:1::f 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

so I ran the command

sudo apt-get update 

I didn't show any error but running gcc version command gave this

$ gcc -v
Command 'gcc' not found, but can be installed with:
sudo apt install gcc

previously I used to have 7.5 but now it is not.

muru
  • 193,181
  • 53
  • 473
  • 722
SriHarsha
  • 63
  • 3
  • 7

3 Answers3

6

Open the terminal and type:

sudo apt install linux-libc-dev 
sudo apt-get -f install
sudo apt install gcc-4.8
karel
  • 110,292
  • 102
  • 269
  • 299
  • could you tell how to remove current version of gcc because i read the comment given by SEKHR i installed latest version once again could you tell me how to remove current version 7.5.0 and use old version sudo apt-get --purge remove gcc i tried by giving verion at end but it didnt work – SriHarsha Sep 28 '20 at 07:00
  • There are two different ways to answer this comment 1. `sudo apt remove gcc-7` (which removes gcc 7.5 in 18.04) **2.** You can change the default gcc version by using the `update-alternatives` command to determine which actual file is referenced by a generic name, for example which actual file is referenced by `gcc`. For more information see the answers to this question: [How to change the default GCC compiler in Ubuntu?](https://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu). – karel Sep 28 '20 at 07:14
  • it worked thank you – SriHarsha Sep 28 '20 at 07:28
4

In your terminal type: sudo apt install gcc and enter. That should install the latest version of gcc.

If you want to install GCC 4.8 specifically, you may follow the post: How to install gcc-4.8.

As GCC 4.8 is available in the default repository on Ubuntu 18.04, then you can simply do

sudo apt-get install gcc-4.8

Or type sudo apt-get install gcc-4 in terminal and press tab. If GCC 4.8 is available it will either auto-complete or show the available versions. If there are versions available other than 4.8 as well, add .8 after sudo apt-get install gcc-4 and press enter to install.

hsbasu
  • 125
  • 6
0

Today, with Ubuntu 22.04.1 LTS, I can use gcc and gfortran version 4.11.2 with old fortran code. I don't think you should bother with gcc version 4.8.

sudodus
  • 45,126
  • 5
  • 87
  • 151