MATLAB Answers


Could anyone know how to use Xcode 5.0 as my C or C++ compiler in MATLAB 2012b or later?

Asked by dai
on 30 Sep 2013
Latest activity Edited by Daniel
on 6 Nov 2013

MAC OS X 10.8.5

Xcode 5.0 (command line tools have installed)

Matlab 2012b

>> mex -setup

    Options files control which compiler to use, the compiler and link command
    options, and the runtime libraries to link against.
    Using the 'mex -setup' command selects an options file that is
    placed in /Users/Yydai168/.matlab/R2012b and used by default for 'mex'. An options 
    file in the current working directory or specified on the command line 
    overrides the default options file in /Users/Yydai168/.matlab/R2012b.
    To override the default options file, use the 'mex -f' command
    (see 'mex -help' for more information).

The options files available for mex are:

1: /Applications/ : 
    Template Options file for building gcc MEX-files
0: Exit with no changes

Enter the number of the compiler (0-1): 1

Overwrite /Users/Yydai168/.matlab/R2012b/ ([y]/n)? y

/Applications/ is being copied to /Users/Yydai168/.matlab/R2012b/


>> mex test.c /Applications/ line 305: llvm-gcc-4.2: command not found /Applications/ line 1326: llvm-gcc-4.2: command not found

    mex: compile of ' "test.c"' failed.

Error using mex (line 206) Unable to complete successfully.


Log in to comment.


No products are associated with this question.

3 Answers

Answer by Tschantz
on 2 Oct 2013

I have the same problem here. Matlab 2013a and Xcode 5.0

  1 Comment

I have solved it.

update matlab 2013a from matlab 2012b

install ”command line tools“ of xcode5.0

and replace ”10.7“ with ”10.8“ in /Applications/

Good luck.

Log in to comment.

Answer by Ken Atwell
on 4 Oct 2013

Dai got it right, replace "10.7" with "10.8" in Here is the MathWorks for this:


Log in to comment.

Answer by Giorgos
on 14 Oct 2013

I have the same problem with Xcode 5.0 and MATLAB 2012b

I know that there is a solution for 2013a and 2013b:

but I need one for 2012b...!

Even this could not help me:

I always get:

/Applications/ line 305: llvm-gcc-4.2: command not found


I have the same problem. Xcode 5.0 & Matlab 2012b.

That error seems to indicate you did not install the command-line tools.

Did you install them as indicated by the solution page 1-FR6LXJ you refer to? It is listed under "*** Before applying the patch *" Step 2.

It seems that with Xcode 5 you can download the command-line tools from:

I am having the same problems... is it possible there are some compatibility problems with the new mac os x 10.9 (mavericks)?

  • I am runnin MATLAB 2012b with Xcode 5.0 (on os 10.9)
  • I have command-line tools installed on Xcode 5.0
  • I've tried installing the patch
  • !xcodebuild -version identifies the correct version of Xcode
  • I have run mex -setup

I still receive the error

Making simulation target "bearing_sfun", ...

/Applications/ -c -O -DMATLAB_MEX_FILE -I/Applications/ -I/Applications/ -I/Applications/ -I/Applications/ bearing_sfun.c /Applications/ line 305: llvm-gcc-4.2: command not found /Applications/ line 1326: llvm-gcc-4.2: command not found

    mex: compile of ' "bearing_sfun.c"' failed.

gmake: * [bearing_sfun.o] Error 1

any ideas? This is becoming a serious time sync!

thanks in advance, dan

[edit] I found this post that solved the problem for my setup

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!