mex in Mac OS X Lion

6 次查看(过去 30 天)
yan
yan 2012-4-29
I need to run cmu target detecting code, it needs to run matlab code and c/c++ code. I had run it in Ubuntu successfully, and now I need to run it in Mac OS X Lion.
I have installed Matlab R2010b, and mex -setup, selected:
/Application/MATLAB_R2010b.app/bin/gccopts.sh Template Options file for building gcc MEX-files
Is that right? Then I hello.c, and error came:
/Application/MATLAB_R2010b.app/bin/mex: line 305: gcc-4.0: command not found
/Application/MATLAB_R2010b.app/bin/mex: line 104: g++-4.0: command not found
How can I fix it?
Thank so much!

回答(3 个)

Walter Roberson
Walter Roberson 2012-4-29
(Note: if you are searching and you see questions about installing gcc-4.2 or gcc-4.3, then those are a different matter dealing with a newer version of MATLAB than you have.)

Ken Atwell
Ken Atwell 2012-4-30
You need to go back to Xcode version 4.0.1, which was current at the time of the release of R2010b (see the link that Walter provided). Apple makes it a tad tricky to get older releases, but they are said to be available to members of the developer program.
This link may be helpful in finding older releases of Xcode.

Peter Tenenbaum
Peter Tenenbaum 2012-6-22
I'm using the current version of Xcode with R2010b and Lion. I was able to get mex to work correctly by editing my mexopts.sh file. In the maci64) stanza I changed gcc-4.0 and g++-4.0 to just gcc and g++; I changed SDKROOT to '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'; and I changed MACOSX_DEPLOYMENT_TARGET to '10.7' .
  2 个评论
Chunyang
Chunyang 2013-3-5
I have tried your answer. However, I still have the same error. Do we need to change other files as mex, etc? As the error says: bin/mex line 306 gcc-4.0 command not found...
Horvathi
Horvathi 2013-8-26
Please note that the mexopts.sh file may exist at different locations. The search order for the option file is the following:
1) ./$OPTSFILE_NAME
2) $HOME/.matlab/<rel_version>/$OPTSFILE_NAME
3) $MATLAB/bin/$OPTSFILE_NAME
Obviously the first one found will be used. You need to make sure that you have modified the correct option file.
In my case (using OSX 10.8 and Matlab R2009b) the second location was the valid. Modifying the correct file according to the description of Peter Tenenbaum solves the problem.
Good luck!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by