gcc and gfortran-9 not showing up after zypper install

Hi I’m recently new to using OpenSuse. I’m trying to install a program called CASTEP that is only compatible with gcc/gfortran version 9. I initially ran “sudo zypper install gcc-fortran” and this downloaded version 10 which isn’t compatible (I used gcc --version to check that it installed properly). Since I couldn’t figure out how to easily remove it, I wiped everything, reinstalled the OS and used “sudo zypper install gcc9-fortran”, which downloaded and installed a series of files related to version 9. This time after I used “gcc --version” it gave the “gcc command not found” text (same for gfortran --version). Is there something else I need to do in order to use g fortran version 9 on Tumbleweed? Thanks!

Hello, assuming that you do have gcc9 and gcc 10 you can use “update-alternatives”.

First check if you have the proper gcc versions installed:

rpm -qa |grep gcc

Now, check where gcc-* are

which gcc

and make sure all versions are there.

ls /usr/bin/gcc*

You should see gcc-9 and gcc-10 packages. Otherwise make sure you do have the gcc9/gcc10 packages installed

Now, you should register the versions of gcc and pick a default, before you continue, become the super user.

su -

Register your gcc-9 with priority 100

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100

Do the same but priority 80 for gcc-10

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 90

You should do something similar to gfortran
Register your gfortran-9 with priority 100

update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-9 100

Do the same but priority 80 for gfortran-10

update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-10 90

As @SJLPHI describes,
When you install a gcc, it should automatically be installed as the default gcc version.
If you install any other gcc from the openSUSE repositories, they’ll be installed side by side but are only available but you’d have to point to those non-default instances in your coding or configure a way to modify the system to reset its default as @SJLPHI describes… Creating a new entry using the Alternatives sub-system makes it very easy to switch between different gcc as your system default.

This kind of question is typically best asked in the Development forums, in particular if you do a search of the Programming/Scripting forum you’ll find past threads about not only gcc but how fortran has been re-packaged and is used nowadays