matlab 2012b how to compile a mex file?

1 view (last 30 days)
Yi
Yi on 15 Jan 2013
I recently installed matlab 2012b mac version for my mac. I want to run a script with command 'mex'. Before I did this, I entered 'mex -setup' in command line and I got
>> 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/liqian/.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/liqian/.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
I chose 1, but when I run my file with mex, the following message showed:
>> build /Applications/MATLAB_R2012b.app/bin/mex: line 305: gcc-4.2: command not found /Applications/MATLAB_R2012b.app/bin/mex: line 1326: g++-4.2: command not found
mex: compile of ' "src/xprj.cpp"' failed.
Error using mex (line 206) Unable to complete successfully.
Error in build (line 2) mex src/xprj.cpp src/prj.cpp src/prj_fanED.cpp src/prj_fanEA.cpp src/prj_para.cpp src/img.cpp src/img_fltTV.cpp src/img_fltSTH.cpp src/cpputils.cpp
What's wrong?

Answers (1)

Walter Roberson
Walter Roberson on 15 Jan 2013

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!