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

2 次查看(过去 30 天)
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/MATLAB_R2012b.app/bin/mexopts.sh :
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/mexopts.sh ([y]/n)? y
/Applications/MATLAB_R2012b.app/bin/mexopts.sh is being copied to /Users/Yydai168/.matlab/R2012b/mexopts.sh
The ERROR:
>> mex test.c /Applications/MATLAB_R2012b.app/bin/mex: line 305: llvm-gcc-4.2: command not found /Applications/MATLAB_R2012b.app/bin/mex: line 1326: llvm-gcc-4.2: command not found
mex: compile of ' "test.c"' failed.
Error using mex (line 206) Unable to complete successfully.

回答(3 个)

Tschantz
Tschantz 2013-10-2
I have the same problem here. Matlab 2013a and Xcode 5.0
  1 个评论
dai
dai 2013-10-3
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/MATLAB_R2013a.app/bin/mexopts.sh
Good luck.

请先登录,再进行评论。


Ken Atwell
Ken Atwell 2013-10-4
Dai got it right, replace "10.7" with "10.8" in mexopts.sh. Here is the MathWorks for this:

Giorgos
Giorgos 2013-10-14
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/MATLAB_R2011b.app/bin/mex: line 305: llvm-gcc-4.2: command not found
  3 个评论
Jorik
Jorik 2013-10-26
编辑:Jorik 2013-10-26
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: https://developer.apple.com/downloads/index.action#
Daniel
Daniel 2013-11-6
编辑:Daniel 2013-11-6
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/MATLAB_R2012b.app/bin/mex -c -O -DMATLAB_MEX_FILE -I/Applications/MATLAB_R2012b.app/toolbox/stateflow/stateflow/../../../simulink/include -I/Applications/MATLAB_R2012b.app/toolbox/stateflow/stateflow/../../../extern/include -I/Applications/MATLAB_R2012b.app/stateflow/c/mex/include -I/Applications/MATLAB_R2012b.app/stateflow/c/debugger/include bearing_sfun.c /Applications/MATLAB_R2012b.app/bin/mex: line 305: llvm-gcc-4.2: command not found /Applications/MATLAB_R2012b.app/bin/mex: 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 http://www.mathworks.com/matlabcentral/answers/103258-mex-on-mavericks-with-r2012b

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by