I have Mountain Lion installed with Xcode 4.5 and Matlab 2012a. I installed and ran the patch supplied on the MathWorks website however I still received the following error:
/Applications/MATLAB_R2012a.app/bin/mex: line 305: llvm-gcc-4.2: command not found
/Applications/MATLAB_R2012a.app/bin/mex: line 1326: llvm-gcc-4.2: command not found
mex: compile of ' "hello.c"' failed.
Error using mex (line 206)
Is there a known solution for that ?
Solution: Open Xcode --> Preferences --> Downloads --> Install "Command Line Tools"
The MathWorks patch is still needed. Resolved issue for me.
You don't need to install XCode. I installed Command Line Tools and then edit the file "/Applications/MATLAB_R2012a.app/bin/mexopts.sh" and
changed CC from gcc-4.2 to llvm-gcc-4.2
changed CXX from gcc-4.2 to llvm-g++-4.2
set SDKROOT to '/'
It's done. Now, you just need to run "mex -setup" in MATLAB
Worked for me (Mac OSX 10.8.2, Command Line Tools - October 2012, MATLAB 2012a)
来源:https://stackoverflow.com/questions/12643236/matlab-2012a-mex-to-work-with-xcode-4-5-on-mountain-lion