I am currently running the latest gcc compiler (version 12.x), but I need to install the an old version of gcc (version 9) to compile some old fortran codes that generate errors when compiled with the most recent gcc compiler.
My question now, is there a way to install two versions of gcc on the same machine? Is there a safer way to do this without messing up the system by replacing the new gcc with the old one?
P.S: I tried installing gcc9 using yay -S gcc9 but the process took more than 2 hours and I had to cancel it due to many fail status for different tests conducted during the installation.
Perhaps the chaotic aur repo has the precompiled - but with this you are on your own - and remember this - it is important with relation to AUR and Chaotic - the packages are built using Arch stable and Manjaro stable is 2-4 weeks behind Arch - so if you decide to go down this road - switch to unstable branch before doing anything else.
I suggest you do some testing using docker container or a virtual machine.
Manjaro docker container can be downloaded form the web site.
You could download one as standalone from the official website and use it without installation. Configure your project to use that one through its absolute path. You can manually delete it when you’re done.
The above link only mentions the availabe gcc versions. It doesn’t show any steps on how to install multiple versions of gcc and how to resolve their conflicts.
The mentioned gcc versions don’t conflict so there is nothing to resolve. It can be installed like any other AUR package, however I would recommend to manual way without an AUR helper.
Thank you all for your responses. I should have mentioned that I am a linux/Manjaro newbie, so some stuff might not be clear to me.
I have already tried to install gcc9 from AUR using yay helper, but it took forever and it never finished the installation.
I will try to install the package from the GUI and see if it works.
I tried the gcc9-bin package and it was installed successfully and was quite fast.
A dumb question, when I do gcc-9 --version, I can see that the compiler is gcc-9, but when I use it to compile the code make CC=gcc-9 the code still uses gcc-12 to generate the executable. Even when I specify a much older version of gcc that is not installed on my system make CC=gcc-4 the process completes with gcc-12.
Any idea how to tackle this (use make with gcc-9 because the above command does not work)?
Thank you so much. After spending some time on this, the following worked for me (I need gcc9 with gfortran):
Installed gcc9-fortran from the add/remove software GUI (AUR package). The installation process took ~3 hours.
Verified that the installation was successful by running the following in the terminal:
gcc-9 --version.
gcc-9 (Arch Linux 9.5.0-1) 9.5.0
Copyright (C) 2019 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.
gfortran-9 --version
GNU Fortran (Arch Linux 9.5.0-1) 9.5.0
Copyright (C) 2019 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.
Built the code by specifying gcc-9 and gfortran-9 as parameters to the make command as:
make CC=gcc-9 FC=gfortran-9
The code now works properly.
I appreciate the discussion that helped me in getting this to work.