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

2 次查看(过去 30 天)
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 个评论
Maurizio De Pitta'
Maurizio De Pitta' 2013-12-5
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by