Error compiling mex with R2013b in OSX 10.9

1 次查看(过去 30 天)
Hi everyone, I want to get started using mex files so I started reading a book on it and can't even get the very first examples to compile. The code is below.
------------------------------------------------------
#include "mex.h"
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray *prhs[])
{
mexPrintf("Hello, mex!\n");
}
------------------------------------------------------
And I get the following error message.
------------------------------------------------------
In file included from helloMex.cpp:1:
In file included from /Applications/MATLAB_R2013b.app/extern/include/mex.h:58:
In file included from /Applications/MATLAB_R2013b.app/extern/include/matrix.h:252:
/Applications/MATLAB_R2013b.app/extern/include/tmwtypes.h:831:9: error:
unknown type name 'char16_t'
typedef char16_t CHAR16_T;
^
1 error generated.
mex: compile of ' "helloMex.cpp"' failed.
------------------------------------------------------
I am running MATLAB 2013b under OS X 10.9 and I have Xcode 5.1 beta 5 installed. I'm wondering if this is a bug due to the beta version of Xcode, but I was wondering if anyone else has seen this problem. Any thoughts welcome.
  2 个评论
Ken Atwell
Ken Atwell 2014-2-24
A stab in the dark: If you rename HelloMex.cpp to HelloMex.c (that is, C compilation rather then C++), what happens?
Bob
Bob 2014-3-18
A different question up here at TMW Answers related to compilation issues suggested downgrading Xcode to v5.02, from 5.1. I just did this (MATLAB 2012b and OS X 10.9.2) and ... it worked. Old versions are in: developer.apple.com/ Good luck!

请先登录,再进行评论。

回答(2 个)

Jon C
Jon C 2014-4-15
编辑:Jon C 2014-4-17
Rather than downgrading Xcode, there are a few solutions listed on this page. The first thing to try if you can use C++ rather than just C is to add
-std=c++11
to CXXFLAGS in your current mexopts.sh.
Or if you have to use C only or can't enable C++11, try one of the alternative solutions given here. One way that seems to work is adding this to the `mex` command line:
-Dchar16_t=UINT16_T

David
David 2014-4-15
Thanks everyone. I have actually given up on mex and am re-writing the entire program in C++ instead.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by