I just built and installed gcc6.3.0 for MATLAB, but I can't set the path to it. I tried
export PATH=/home/mo/GCC-6.3.0:$PATHbut this still gives the path to default gcc9.3.0. Ubuntu20.04.
52 Answers
You would have to update the gcc configuration to make that your default compiler.
Add the compiler to the list of available compilers.
sudo update-alternatives --install /usr/bin/gcc gcc /path/to/installation/bin/gcc-6.3 6Activate the compiler. This will prompt you to select a compiler.
sudo update-alternatives --config gccVerify whether the changes have taken effect with gcc --version
For security reasons, it is not recommended to add directories especially to the beginning of the path, as explained in this answer.
2An easy way for me was to export gcc's path in terminal as:
export PATH=/home/mo/GCC-6.3.0/bin:$PATHand then open MATLAB from this terminal window as:
cd /usr/local/MATLAB/R2019a/bin
./matlabcheck gcc path in MATLAB:
!which gcc