Closed jeanluct closed 9 years ago
This page has the helpful line about mex -setup
: "If you have multiple compilers, MATLAB displays a message with links to set up a different compiler." Except it doesn't:
$ mex -setup
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. In the near future
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, execute one from the following:
mex -setup C++
mex -setup FORTRAN
How are we supposed to tell MEX
about the different compilers we have?
(Continuing discussion, not providing a solution)
From inside MATLAB, configurations for different (supported) compilers can be read using mex.getcompilerconfigurations
http://www.mathworks.com/help/matlab/ref/mex.getcompilerconfigurations.html
For example, on my system:
>> a = mex.getCompilerConfigurations('C','Supported').Details
a =
CompilerConfigurationDetails with properties:
CompilerExecutable: '/usr/bin/xcrun -sdk macosx10.9 clang'
CompilerFlags: '-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysro...'
OptimizationFlags: '-O2 -DNDEBUG'
DebugFlags: '-g'
LinkerExecutable: ''
LinkerFlags: ''
LinkerOptimizationFlags: '-O'
LinkerDebugFlags: '-g'
SetEnv: 'CC="/usr/bin/xcrun -sdk macosx10.9 clang"
CXX="/usr/bin/xcrun -sdk maco...'
CommandLineShell: ''
CommandLineShellArg: ''
Configurations scripts for different compilers are stored in xml files that on my computer reside in:
/Applications/MATLAB_R2014b.app/bin/maci64/mexopts/
I guess if we wanted to run a different compiler, we would generate an xml
file like this and pass it to mex
using -f
option. I haven't tried it, though.
Sorry about that, writing in a hurry. I added more detail now.
Did Alex try setting global variable, via export
or setenv
as well?
Yeah, I was looking at those XML files. Seems a pain and hard to describe in the guide.
We tried setting CXX
globally, no help.
Did you try using update-alternatives
on linux for less painful switching of compilers?
http://lektiondestages.blogspot.com/2013/05/installing-and-switching-gccg-versions.html
Changing the XML file doesn't seem to work...
Maybe alternatives is the way to go, but it's a pain to describe in the guide.
Script and updated guide in 622d50c. Not very satisfying: the script devel/gcc-alternatives
basically sets things up automatically, as long as it's GCC 4.x. This script is not distributed formally with braidlab and I put it under devel
for convenience.
Ok, Alex F was able to compile on Ubuntu 14.10 with Matlab 2014a following the guide, so this seems fixed enough.
What a pain: the instructions in the guide, e.g.
make CC=gcc-4.7 CXX=g++-4.7
, do not work as intended. It seemed to work on my system, but when trying on Alex F's Ubuntu 14.10 there was a problem: since 14.10 uses GCC-4.9 by default, mex can't support it.The problem is that the
CXX=
settings are not passed to MEX. So how are we supposed to specify a compiler for MEX? Mystifying... (hello issue #67...).