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