Filter löschen
Filter löschen

Error compiling mex with R2013b in OSX 10.9

1 Ansicht (letzte 30 Tage)
David
David am 24 Feb. 2014
Kommentiert: Tarek am 3 Mai 2014
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 Kommentare
Ken Atwell
Ken Atwell am 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
Bob am 18 Mär. 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!

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Jon C
Jon C am 15 Apr. 2014
Bearbeitet: Jon C am 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

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

Kategorien

Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by