필터 지우기
필터 지우기

How to set the c compiler of matlab2013a in OSX 10.9?

조회 수: 2 (최근 30일)
Yujia
Yujia 2014년 3월 13일
편집: Jon C 2014년 5월 29일
I am using matlab 2013a to run a simulink with matlab function. I tried basically everything on the Q&A section but I could get it working.
My current version of matlab is 2013a. I have downloaded Xcode 5.1 and also the command line tools. The version of OSX is 10.9.
When I "mex -setup"
Options files control which compiler to use, the compiler and link command
options, and the runtime libraries to link against.
Using the 'mex -setup' command selects an options file that is
placed in /Users/WU/.matlab/R2013a and used by default for 'mex'. An options
file in the current working directory or specified on the command line
overrides the default options file in /Users/WU/.matlab/R2013a.
To override the default options file, use the 'mex -f' command
(see 'mex -help' for more information).
The options files available for mex are:
1: /Applications/MATLAB_R2013a.app/bin/mexopts.sh :
Template Options file for building MEX-files
0: Exit with no changes
Enter the number of the compiler (0-1): 1
Overwrite /Users/WU/.matlab/R2013a/mexopts.sh ([y]/n)? y
/Applications/MATLAB_R2013a.app/bin/mexopts.sh is being copied to /Users/WU/.matlab/R2013a/mexopts.sh
Also when I was trying to run the simulink it shows:
Making simulation target "cruise_control_model_sfun", ...
/Applications/MATLAB_R2013a.app/bin/mex -c -O -DMATLAB_MEX_FILE -I/Applications/MATLAB_R2013a.app/stateflow/c/mex/include -I/Applications/MATLAB_R2013a.app/stateflow/c/debugger/include cruise_control_model_sfun.c In file included from cruise_control_model_sfun.c:3: In file included from ./cruise_control_model_sfun.h:6: In file included from /Applications/MATLAB_R2013a.app/stateflow/c/mex/include/sfc_sf.h:33: In file included from /Applications/MATLAB_R2013a.app/simulink/include/mwmathutil.h:23: /Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t' typedef char16_t CHAR16_T; ^ 1 error generated.
mex: compile of ' "cruise_control_model_sfun.c"' failed.
gmake: * [cruise_control_model_sfun.o] Error 1
Error using cruise_control_simulation (line 42) Error using targetman>throw_make_error (line 578) (SLSF Diagnostic)
Many thanks
  댓글 수: 4
Johan
Johan 2014년 3월 18일
I've just started to have the same char16_t issue. OSX 10.9, recently updated to Xcode 5.1, Matlab 2011a. The interesting thing is that when I download the latest version of the simulink model I'm working on from svn, it compiles and runs fine, but when I change any of the embedded matlab code blocks in it, it starts throwing this undefined char16_t error.
The compiler output you asked for:
>> mex -v timestwo.c
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /Users/***/.matlab/R2011a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2011a.app
-> CC = gcc
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = gcc
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011a.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
-> gcc -c -I/Applications/MATLAB_R2011a.app/extern/include -I/Applications/MATLAB_R2011a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "timestwo.c"
In file included from timestwo.c:1:
In file included from /Applications/MATLAB_R2011a.app/extern/include/mex.h:58:
/Applications/MATLAB_R2011a.app/extern/include/matrix.h:335:13: error: unknown type name 'char16_t'
typedef char16_t mxChar;
^
1 error generated.
mex: compile of ' "timestwo.c"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
Johan
Johan 2014년 3월 18일
Now downloaded Xcode 5.0.2 again and everything works with this. The separately installed command line tools remain at version 5.1.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jon C
Jon C 2014년 5월 29일
편집: Jon C 2014년 5월 29일
The char16_t error is the same the one in both this and this other question, although those both pertain to a C++ solution rather than C.
The C solution would be to typedef or define the char16_t type, as described on this page. Basically, on the mex command line, add:
-Dchar16_t=uint16_t
OR edit the .c source, just before #include "mex.h":
typedef uint16_t char16_t;

카테고리

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