problem compiling mex file

1 visualización (últimos 30 días)
Miranda
Miranda el 1 de Jun. de 2015
Comentada: Miranda el 1 de Jun. de 2015
Hi,
I wrote a very simple mex file, and am having problems compiling it.
Initially, the error I got was:
/Applications/MATLAB_R2012b.app/bin/mex: line 305: gcc-4.2.1: command not found
/Applications/MATLAB_R2012b.app/bin/mex: line 1326: gcc-4.2.1: command not found
mex: compile of ' "distxL.c"' failed.
So, I followed the advice on the help page and ran "mex -setup c", pressed "1" to copy over the mex file to my directory, and then searched for the line that said CC='gcc-4.2' and changed it to CC='gcc'. This is because when I type "!which gcc" in matlab, I get the response "/usr/bin/gcc".
Now, when I try to compile the mex file, I get the following problem:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
In file included from distxL.c:18:
In file included from /Applications/MATLAB_R2012b.app/extern/include/mex.h:58:
In file included from /Applications/MATLAB_R2012b.app/extern/include/matrix.h:294:
/Applications/MATLAB_R2012b.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t'
typedef char16_t CHAR16_T; ^ 1 error generated.
mex: compile of ' "distxL.c"' failed.
This is apparently a problem with the include file "math.h", which I need for the functions "sqrt" and "floor".
Can you please help me to resolve this?
For more background: I have a Mac, OSX 10.9.5, running Matlab version 2012b, and Xcode version 3.2.6. (I know these are all old, but don't want to update for various reasons.) The last time I opened Xcode it asked me to update my compiler, which I did. Before this, all the mex files were compiling just fine. When I type "gcc --version" in the terminal, I get the following output:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix
I do not understand any of this.
Thanks for your help, Miranda
  2 comentarios
Adam
Adam el 1 de Jun. de 2015
I don't usually need to troubleshoot mex thankfully as it generally just works after setup, but if I remember correctly the mex setup command asks you to choose a compiler from those available on your machine so you shouldn't be needing to edit setup files for the gcc version afterwards.
Your error message suggests it is looking in folders of v4.2.1 for includes so removing the -4.2 from the gcc command doesn't sound advisable to me.
I may be totally wrong though...
Miranda
Miranda el 1 de Jun. de 2015
Are you able to explain how to choose a compiler? I am asked to enter a number between 0 and 1, as follows:
The options files available for mex are:
1: /Applications/MATLAB_R2012b.app/bin/mexopts.sh :
Template Options file for building gcc MEX-files
0: Exit with no changes
Enter the number of the compiler (0-1):
I'm not sure how to enter the number corresponding to my compiler (nor even what number that should be)?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by