Installing gfortran-15 problem

The method @Beliavsky gave nearly 3 years ago to install the latest gfortran no longer works. I use Ubuntu 24.10. This is what I tried today:

(lf) john:~$ sudo apt install gfortran-15
Error: Unable to locate package gfortran-15
(lf) john:~$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'Types: deb
URIs: https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/
Suites: oracular
Components: main
'
Description:
Toolchain test builds; see https://wiki.ubuntu.com/ToolChain

More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Found existing deb entry in /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-oracular.sources
Hit:1 http://archive.ubuntu.com/ubuntu oracular InRelease                      
Hit:2 http://security.ubuntu.com/ubuntu oracular-security InRelease            
Hit:3 http://archive.ubuntu.com/ubuntu oracular-updates InRelease              
Ign:4 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu oracular InRelease
Err:5 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu oracular Release
  404  Not Found [IP: 185.125.190.80 443]
Reading package lists... Done
E: The repository 'https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu oracular Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
(lf) john:~$

It’s not clear whether Ubuntu offers any way to get gfortran-15.

It does. But non-LTS packages might become unavailable more often than the ones for LTS releases.

If you go here, you’ll notice Oracular is no longer an option, and you’ll need to change the PPA list file to point to Plucky.

(You might want to upgrade your machine to Plucky first, to avoid conflicting toolchains)

My method:

git clone git://gcc.gnu.org/git/gcc.git
cd gcc
git checkout releases/gcc-15.1.0
./contrib/download_prerequisites
./configure --program-suffix=15.1 -enable-languages=c,c++,fortran --enable-libgomp --enable-bootstrap --enable-shared --enable-threads=posix --with-tune=generic --disable-multilib
make -j 
sudo make install

This will put gcc-15.1 in your /usr/bin/

2 Likes

Thank you @jorgeg but on doing what you did I had this problem with
make -j which gave an error message beginning thus:

cc1plus: fatal error: gengtype-lex.cc: No such file or directory
compilation terminated.

and ending thus:

make[1]: Leaving directory '/home/john/gcc'
make: *** [Makefile:1110: all] Error 2

So I copied gengtype-lex.cc from another directory where a previous attempt to install gfortran-15 had failed and got the same error message from make -j in spite of this (remember my time zone is 12h ahead of UT):

(lf) john:~/gcc$ ls -o gengtype*
-rw-rw-r-- 1 john 99343 May  1 11:17 gengtype-lex.cc
(lf) john:~/gcc$ 

What should I do now?

did download_prerequisites complete correctly? a missing something sounds like a problem like this

Yes. Evidence:

(lf) john:~$ cd gcc
(lf) john:~/gcc$ ./contrib/download_prerequisites
gettext-0.22.tar.gz: OK
gmp-6.2.1.tar.bz2: OK
mpfr-4.1.0.tar.bz2: OK
mpc-1.2.1.tar.gz: OK
isl-0.24.tar.bz2: OK
All prerequisites downloaded successfully.
(lf) john:~/gcc$ 

Now trying

./configure --program-suffix=15.1 -enable-languages=c,c++,fortran \
--enable-libgomp --enable-bootstrap --enable-shared --enable-threads=posix \
--with-tune=generic --disable-multilib

yet again. On doing so I still got the same error:

  -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
	-o build/genconstants.o ../.././gcc/genconstants.cc
cc1plus: fatal error: gengtype-lex.cc: No such file or directory
compilation terminated.

And ~/gcc/gengtype-lex.cc is still there from this morning!

weird ! mine works following those instructions, what gcc are you using to compile it?

There’s someone else that had this, see here

The gcc I used to try to compile gfortran-15 would seem to be 14.2.0:

(lf) john:~$ gcc --version
gcc (GCC) 14.2.0
Copyright (C) 2024 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.

(lf) john:~$ 

I wonder whether this sort of thing is why the SciPy people have trouble with gfortran. (See the Conda + Fortran = Profit discussion.) In the meantime I suppose I’ll have to try installing gfortran 15 from source using their instructions designed for earlier versions of both gfortran and Ubuntu :frowning:

1 Like

yeah :frowning: I don’t know exactly what is going wrong for you since this has worked me every time, including building 15.1.

First attempt at installing gfortran 15 from source ran for over 4 hours and then failed complaining there was no " at the end of my string of configure options. I found that if the options were longer than one screen line, tempting a bash user to use \ at the end of a line, then configure does not interpret \ in the same way. Rewriting my shell script to avoid it I got a compiler that works! Pity that conda seemed not to have version 15, which might have saved a lot of time. It would be nice if configure checked its options for validity before running.

1 Like

nooooooo so annoying that you ran into that…but glad that it now works! :slight_smile: if you are not afraid of heat you can always make -j I think my poor little laptop suffers when I do that haha

Just to confirm that this works perfectly on an “oldish” Linux Mint 21.3, thanks for sharing this information.

Is there a way to estimate how much RAM make -j would require? If I don’t reduce the number of threads with make -j, I run out of RAM and I’d like to test if using a swapfile, instead of reducing the number of threads, is faster.

to my knowledge there is no other way other than “the vibes” to feel this one out. I usually run make -j and go get some coffee with top running in a separate tab and if it dies, I do take nproc/2 and rerun haha. Sorry for the lack of a scientific approach.

If you see the movie “The Castle” and see the scene in court about “vibes”, this is exactly it.

2 Likes

By any chance, do you have a reference go-to page with the different options for ./configure?

This page contains all the supported ./configure options

The following page contains the complete installation procedure

1 Like

Brilliant, thanks!

1 Like

That’s exactly what I do. Not nice to make your system crash, though.

When installing a previous gfortran version I found the using make -j 4 was helpful (saving time or space) and so I still use it.

With Ubuntu you can use just make -j (or make --jobs) and it will adapt to the number of cores of your CPU.

In FreeBSD, the number of threads must be explicitly set, for example make -j 4.

In MSYS2/Windows, the display is awful (everything mixed even inside lines :laughing:), but it also works…