I would like to build MEX functions from C/C++ source code to enable MATLAB script access, but my current version of Fedora has a newer and incompatible GCC. I have tried removing the installed GCC and installing a 4.7.x version of GCC using sudo dnf gcc-4.7.x (with x = [1, 2, 3, 4]), but it seems that none of those versions are hosted on the Fedora package repositories.
Is there any other way to install older versions of GCC on the newer Fedora versions?
You'll have to download gcc source, and compile gcc yourself. Fedora repositories are release-specific. gccs from earlier releases of Fedora are not included in subsequent releases of Fedora.
Although it's possible to download earlier versions of gcc manually, from the appropriate release of Fedora, it is unlikely that rpm will agree to install it, due to version conflicts. It's possible that someone will helpfully suggest using --force
to force-install an incompatible version of gcc. Such advice, alas, is fairly likely to result in an unbootable brick.
So the only practical answer is to download and build gcc yourself; with a custom configuration that installs gcc into a non-default location, in order to avoid overwriting the system-installed libstdc++
. Not a trivial task, having done this myself, some years ago.
TL;DR: if you have to ask such a question, it's not possible.