MATLAB Answers


mex *.cpp under MATLAB 2013b and Xcode 5.0

Asked by Jan
on 13 Mar 2014
Latest activity Answered by Jan
on 14 Mar 2014

Compiling this simple code:

#include <math.h>
#include <matrix.h>
#include <mex.h>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
  mexPrintf("Hello World!\n");

results in the following error when I call " mex helloworld.cpp ":

In file included from helloworld.cpp:2:
In file included from /Applications/
/Applications/ error: unknown type name 'char16_t'
typedef char16_t CHAR16_T;
1 error generated.
      mex: compile of ' "helloworld.cpp"' failed.
Unable to complete successfully.

However, when I call " mex helloworld.c " it works fine. Can someone help me to fix that issue? I need to use the .cpp compiler for a project that I'm working on.


Log in to comment.

2 Answers

Answer by Jan
on 14 Mar 2014
 Accepted Answer

Thanks Jacques, you were right. The compiler didn't use c++11. This solved my problem:

Add -std=c++11 to CXXFLAGS in your current



Log in to comment.

Answer by Jacques
on 13 Mar 2014

char16_t is available since the c++11 version of the c++ standard. Your compiler might not comply with this version.

Look at the file /Applications/ Does it uses char16_t ?


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today