Main Content

Change Default gcc Compiler onLinuxSystem

MATLAB®supports only one compiler for each language on Linux®platforms. If you have multiple compilers installed, the default compiler might not be a compiler that MATLAB supports. To determine the default gcc compiler for your system, in MATLAB, type:

!which gcc

To change the default compiler, choose one of these options.

  • Change the system$PATHvariable. When you change the path, this compiler becomes the default for all applications on your system.

    To change the$PATHvariable, add the folder containing the compiler that MATLAB supports to the beginning of the path. Refer to your operating system documentation for the correct command to use.

  • Select a compiler that MATLAB supports when running themexcommand. To change the compiler, use thevarnamevariable set toGCC, in uppercase letters.

    For example, if the currently supported gcc compiler is version 6.3 and it is installed in the/usr/bin/gcc-6.3folder on your system, to buildtimestwo.c, type:

    copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.c'),'.','f') mex-vGCC='/usr/bin/gcc-6.3'timestwo.c

Note

Themex -setupcommand does not change the default compiler on Linux.

Related Topics

External Websites