Would you be able to use docker containers, as it might be the easiest workaround, if you cannot install anything on your machine?
This would allow you to use a newer Ubuntu and GCC version, which should work.