I am running Matlab R2012b and updated to Mac OS Mavericks and Xcode 5. Now I can't compile my c++ code into mex files anymore: /Applications/MATLAB_R2012b.app/bin/mex: line 305: llvm-gcc-4.2: command not found /Applications/MATLAB_R2012b.app/bin/mex: line 1326: llvm-g++-4.2: command not found
What to do?

2 Kommentare

Fabio
Fabio am 25 Okt. 2013
I have the same problem here!!!
Yimeng Zhang
Yimeng Zhang am 28 Okt. 2013
Can anybody provide a solution for R2013a? Thanks.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

rmm
rmm am 25 Okt. 2013
Bearbeitet: rmm am 25 Okt. 2013

3 Stimmen

Hi,
I had the same problem. It seems that the new version of llvm-gcc is version 5.0. You can confirm the same for your system by typing
llvm-gcc --version
in terminal.
Assuming you've previously downloaded the MEX patch provided by Mathworks, my work-around was to modify the MacOSX 10.8 patch in the mexopts.sh file. For me this file was located in
/Users/<myname>/.matlab/R2012b/
At the bottom of the mexopts.sh file find the code block for #PATCH: MacOSX10.8 . Modify the following three lines to:
CC='llvm-gcc'
CXX='llvm-g++'
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/'
The version number was deleted from the definition of the first two variables. In the third variable's definition MacOSX10.8.sdk was changed to MacOSX10.9.sdk. Oddly, changing the the version from 4.2 to 5.0 in the first variables' definitions did not solve the problem, but completely deleting the version number did.
These changes allowed me to compile a project that was throwing the same error you were getting. Whether this work-around is best practice or not I don't know.

8 Kommentare

Felix
Felix am 27 Okt. 2013
Thanks, this worked perfectly.
Tom K
Tom K am 28 Okt. 2013
Thanks I was looking for this solution, I got as far as to change to 10.9 but didn't think to change the gcc/g++ versions so thank you.
Daniel
Daniel am 6 Nov. 2013
excellent work...this seemed to get me back running again! cheers
Sajjad
Sajjad am 5 Dez. 2013
Fantastic job...worked perfectly...Thanks
Christopher Keown
Christopher Keown am 29 Jan. 2014
OMG, thank you! This worked beautifully.
Gabriele Pompa
Gabriele Pompa am 11 Jan. 2015
Mamma mia, I love you!
Florian Chapotot
Florian Chapotot am 3 Dez. 2015
This solution from rmm also works with R2012b on Mac OSX 10.11 Yosemite ! Thank you
Arnaud Delorme
Arnaud Delorme am 18 Apr. 2016
First, type "mex -setup" to make sure the file mexopts.sh exists. Second, make sure the SDK folder exist /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/, if not look list the content of /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ to see which one to use. Then it worked for me.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

xinhao liu
xinhao liu am 25 Okt. 2013

1 Stimme

You should soft link the llvm compiler, In the terminal:
cd /usr/bin
sudo ln -fs clang llvm-gcc-4.2
sudo ln -fs clang++ llvm-g++-4.2
I think the Mathworks will release some patch for the problem later, but right now it works for me.

2 Kommentare

Rasim Dilan
Rasim Dilan am 28 Okt. 2013
Thank you. This works well for me.
huijing
huijing am 9 Nov. 2013
tried out so many solutions, finally this works for me, thank you very much

Melden Sie sich an, um zu kommentieren.

Xu Tian
Xu Tian am 15 Nov. 2013

0 Stimmen

WOW!!! Thanks a lot! That does work for me!
Chris
Chris am 14 Okt. 2014

0 Stimmen

Does this work around work for C-code as well?

Kategorien

Gefragt:

am 25 Okt. 2013

Kommentiert:

am 18 Apr. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by