How to Use an Older Version of Gcc in Linux

how to install older version of gcc -3 or gcc-4 in ubuntu 20

Hope you have updated package manager, in doubt you can run following commands (in the same order given, which should run without errors):

sudo apt-get update
sudo apt-get upgrade

Then you need to ensure build-essential installed:

sudo apt-get install build-essential

After that you can install required version of gcc (example: gcc-4):

sudo apt-get install gcc-4

Now the part of selecting specific version of gcc by following command:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4 4
sudo update-alternatives --config gcc

By this way you can switch between multiple versions of gcc too. The second command in the last step will give you a menu like option to select among available(installed) gcc versions to be set.

Compile older version of gcc

Here is a link that seems good to start with:
http://www.linuxquestions.org/questions/linux-from-scratch-13/why-cannot-compute-suffix-of-object-files-350753/

How to install an older version of gcc on Fedora

Build gcc-8.2.0

# dnf install gcc-c++ flex bison binutils-devel elfutils-devel elfutils-libelf-devel texinfo doxygen zlib-devel
tar xvf gcc-8.2.0.tar.xz
cd gcc-8.2.0/
tar xvf mpfr-4.0.2.tar.xz && mv -v mpfr-4.0.2 mpfr
tar xvf gmp-6.1.2.tar.xz && mv -v gmp-6.1.2 gmp
tar xvf mpc-1.1.0.tar.gz && mv -v mpc-1.1.0 mpc
cd ../
mkdir build-gcc820
cd build-gcc820/
../gcc-8.2.0/configure --prefix=/usr/local/gcc82 --program-suffix=82 --enable-languages=c,c++,fortran --disable-multilib --disable-libstdcxx-pch --with-system-zlib
make
# make install

Result : gcc82-c++-8.2.0-2.fc29.x86_64.rpm https://drive.google.com/file/d/1qGPvF9jc6CiI1a0-c3I4Zj4vxajEwSzc/view?usp=sharing
Provides /usr/bin/{gcc8, g++8, gfortran8}

Install : # dnf install Downloads/gcc82-c++-8.2.0-2.fc29.x86_64.rpm



Related Topics



Leave a reply



Submit