Error compiling mex with R2013b in OSX 10.9
1 view (last 30 days)
Show older comments
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 Comments
Ken Atwell
on 24 Feb 2014
A stab in the dark: If you rename HelloMex.cpp to HelloMex.c (that is, C compilation rather then C++), what happens?
Bob
on 18 Mar 2014
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!
Answers (2)
Jon C
on 15 Apr 2014
Edited: Jon C
on 17 Apr 2014
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
See Also
Categories
Find more on Troubleshooting in MATLAB Compiler SDK 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!