GCC 14 on Fedora 42

I had to upgrade to Fedora 42, but now the default GCC is 15, and I have some code that does not compile with it (the code is at fault, but I cannot modify it).

So, I found this page which mentions, correctly, that package gcc-14 exists, and I installed it. Now I want this GCC to be the default one.

The page suggests this:

  1. Using the alternatives system:
sudo alternatives --config gcc

This displays a menu allowing you to select the default gcc command.

But this does not work at all for me: running the command does nothing, and alternatives --list does not even contain gcc anywhere.

Is that page some kind of AI-bullshit that sometimes gets it right, sometimes hallucinates things? Is alternatives supposed to help here?

Otherwise, is there a way of getting gcc-14 as default replacement for gcc on Fedora 42, other than some manual hack?

You should specify the correct path like this:

I have seen people use explicit standard versions to get code to compile.
I think it’s the --std option they use, c++17 maybe?

If you are trying to compile C code and it compiles cleanly with gcc14, a simpler method might be to use gcc15 with -std=gnu17 to compile.

1 Like