Borrar filtros
Borrar filtros

specific mex compiler matlab linux 64 bit

37 visualizaciones (últimos 30 días)
Andrea Nicastro
Andrea Nicastro el 30 de Mzo. de 2017
Comentada: Andrea Nicastro el 3 de Abr. de 2017
HI everybody, I am trying to set up a specific compiler for my mexfiles in matlab under debian 64bit. First of all I have tried to run
mex -setup -v
but it does not provide any option as I expected
Verbose mode is on.
... Looking for compiler 'gcc' ...
... Executing command 'which gcc' ...Yes ('/usr/bin/gcc').
... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/6/libstdc++.so').
Found installed compiler 'gcc'.
... Looking for compiler 'gcc' ...
... Executing command 'which gcc' ...Yes ('/usr/bin/gcc').
... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/6/libstdc++.so').
Found installed compiler 'gcc'.
MEX configured to use 'gcc' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
Then I tried to copy /usr/local/MATLAB/R2017a/bin/mexopts.sh in ~/.matlab/R2017a/mexopts.sh and modify the configurations as in
CC='/usr/bin/gcc-4.9'
and analogously for g++. However the following output shows that this didn't work, either
>> cc = mex.getCompilerConfigurations('C','Selected')
cc =
CompilerConfiguration with properties:
Name: 'gcc'
Manufacturer: 'GNU'
Language: 'C'
Version: ''
Location: '/usr/bin/gcc'
ShortName: 'gcc'
Priority: 'A'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: ''
LinkerVersion: ''
MexOpt: '/home/anicastro/.matlab/R2017a/mex_C_glnxa64.xml'
and /usr/bin/gcc points to gcc 6.3. I tried also by changing the file in /usr/local/MATLAB/R2017a/bin/mexopts.sh but the result is the same.
I have little experience with mex files, how can I solve this?
Cheers
Andrea

Respuestas (1)

Sangeetha Jayaprakash
Sangeetha Jayaprakash el 3 de Abr. de 2017
It looks like you are trying to use gcc version 4.9 compiler with the "mex" function.
1. To view all the MATLAB compatible compilers for compiling C code, execute the following:
>> mex -setup C
2. If you are unable to view the GCC-4.9 compiler in the list of available compilers, use the GCC option along with the mex command to point at a supported compiler version. Also, make use of the verbose option (-v flag) in order to view the current settings of GCC, and confirm the changes made as shown below:
>> mex -v GCC='path/to/gcc/bin/gcc-4.9' path/to/somefile.c
I hope this works for you.
  1 comentario
Andrea Nicastro
Andrea Nicastro el 3 de Abr. de 2017
Hi, thank you for the answer.
1. As I was saying in my original post, your suggested solution is the first one I tried, but it does not work.
2. I already tried this solution, but it is highly unpractical for large toolboxes that provide a compilation mechanism.
I'll try to see if there is another way to proceed

Iniciar sesión para comentar.

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by