mex *.cpp under MATLAB 2013b and Xcode 5.0

조회 수: 2 (최근 30일)
Jan
Jan 2014년 3월 13일
답변: Jan 2014년 3월 14일
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/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 ' "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.

채택된 답변

Jan
Jan 2014년 3월 14일
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 mexopts.sh.

추가 답변 (1개)

Jacques
Jacques 2014년 3월 13일
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/MATLAB_R2013b.app/extern/include/tmwtypes.h Does it uses char16_t ?

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by