The SET command shows this path: "C:\MinGW\bin". After some googling I've found out that apparently it's best to use this directory, otherwise issues might arise with MinGW.
Do you really have gcc 2.95 installed? That is very,very,very old (dating from 1999!). That might also be a problem.
I've installed MinGW-w64, the GCC whose version is shown is the one that comes with FreePascal. I guess it's really old.
Strangely, GCC seems to work for me with CodeBlocks! It's the only IDE where it works, because you can directly set the paths to everything in the options. I've tried other IDEs like Geany, VSCode, CodeLite, but with no luck, GCC can't find its own libraries. But really, CodeBlocks isn't great for my purposes, I need to be able to use a regular command prompt.
At stackoverflow they've suggested that my MinGW installation is just faulty. I'm going to install the latest MSYS2 this time and see if that works. I'll write in the thread again if it does.