specific mex compiler matlab linux 64 bit
29 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Sangeetha Jayaprakash
on 3 Apr 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.
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!