Building mrtrix3 on RHEL 7

Yes, that looks like a similar problem to this thread, which is basically an incomplete compiler installation. In your case, the compiler executable is in a non-standard location, and when it tried to link the final executable with the c++ libraries, it can’t find the correct version of it because their location isn’t in the linker search path. Working with custom compilers can be a bit tricky from that point of view, and getting it right would require setting the correct CXX, CFLAGS, and LDFLAGS, in your case probably like this:

export CXX=/usr/local/bin/gcc
export CFLAGS="-isystem /usr/local/include"
export LDFLAGS="-L/usr/local/lib"

You may find that’s sufficient to compile – but probably not to run anything you’ve just compiled, which is still required for the configure step. For that, you’d need to set the path for the dynamic linker. The simplest way to do this is probably:

export LD_LIBRARY_PATH=/usr/local/lib

With that, you might be able to run through the configure and build steps.

If that works, you’ll also need to set the LD_LIBRARY_PATH variable before invoking any of the newly generated executables… However, as I’d hinted in the previous thread, that’s generally discouraged, the better way to set the linker search path is by adding an entry to /etc/ld.so.conf.d/, as explained e.g. here.

If all else fails, you could try this script, which I’ve put together based on these instructions (from @rsmith), which might get you most of the way - but it does involve building all dependencies from source, which is a fair bit more involved than might be required in your case…