Compiled MEX function is not recognized in MATLAB R2013a on MAC OX 10.8 Mount Lion

4 views (last 30 days)
Dear all, I am trying to use mex functions on my new MACBook Pro (running MATLAB R2013). I installed XCode 5.2 (latest version). I updated mexopts.sh to recognize Mount Lion (10.8). When I compile by:
> mex -v -g myfile.c -output myfile_ex
The compilation seems to go smoothly (myfile_ex.mexmaci64 is created). Yet when I invoke my function, I get:
myfunction_ex(input1) >> Undefined function "myfunction_ex" for input arguments of type "double".
On other platforms (Window Vista Pro, Ubuntu 13.04) this file is successfully compiled. I have no clue why on MAC is not working. It seems that my MATLAB is not able to recognize my MEX function. And it does so with any mex function that I try to compile. Simply the *.mexmaci64 function is not recognized by matlab.
Any help will be really appreciated.
Cheers, Maurizio
  1 Comment
Maurizio De Pitta'
Maurizio De Pitta' on 5 Dec 2013
Just an update to this issue.
It seems that even if a mex function looks compiled successfully, but then matlab is not able to recognize it, then it is because some of the library internally were not linked correctly. Weird enough is that no warning message is provided.
It will need further thoughts, but changing the file extension from C to CPP, and thus compiling it by the g++ compiler solved the issue.
Alternatively, you can keep the C extension but make sure that the CLIBS flag in your meshopts.sh file (/Applications/MATLAB_$VERSION$.app/bin) includes -lstdc (and not -lstdc++ as in the original version).
So, apparently there was a wrong setting in the mexopts.sh file.

Sign in to comment.

Answers (0)

Categories

Find more on Introduction to Installation and Licensing 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!