mex in Mac OS X Lion
3 views (last 30 days)
Show older comments
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!
0 Comments
Answers (3)
Walter Roberson
on 29 Apr 2012
(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.)
0 Comments
Ken Atwell
on 30 Apr 2012
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.
0 Comments
Peter Tenenbaum
on 22 Jun 2012
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 Comments
Chunyang
on 5 Mar 2013
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
on 26 Aug 2013
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!
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!