1. Open the terminal window in LINUX and execute the command:
$ which gcc
This will provide the symbolic link (softlink) to the default version of GCC.
2. Navigate to the directory which has this softlink.
Change the softlink to point to the version of GCC that you want to use.
For example, for a standard GCC version 4.7 installed (where the compiler command is put at /usr/bin/gcc-4.7),
this can be done using the following command:
$ sudo ln -f -s /usr/bin/gcc-4.7 gcc
Here "gcc" is the name of the softlink determined in step 1.
If you execute the command “ls –l gcc” on the terminal, it will indicate that softlink points to gcc-4.7.
Note: As an alternative to steps 1 and 2 above, you should also be able to use the following one liner:
$ sudo ln -s -f `dirname \`which gcc\``/gcc-4.3 `which gcc`
3. Now open MATLAB and execute the following command:
>> !gcc --version
This command reflects the version of GCC compiler that is currently being used by MATLAB.
If you specify gcc-4.7 as above, it will indicate “gcc-4.7”.
You may also use the verbose mode ("-v" flag) to display detailed build information:
>> mex -v timestwo.c
Best Answer