Clear Filters
Clear Filters

Overriding compiler switch in MEX

6 views (last 30 days)
Siva
Siva on 2 Aug 2019
Edited: Siva on 4 Aug 2019
Hello,
I am using MATLAB 2019a and trying to create a MEX file from Fortran code.
My Fortran compiler is 'Intel Parallel Studio XE 2019 for Fortran with Microsoft Visual Studio 2017'.
The MEX configuration has a default compiler switch /integer-size:64. However, I have some legacy Fortran code, where integers are not explicitly declared, and I don't want these to be taken as 64-bit integers. So, I try to override this by
mex -v COMPFLAGS='$COMPFLAGS /integer-size:32' -largeArrayDims filename
But this results in the command line
ifort /c /nologo /fpp /Qprec /MD /fp:source /assume:bscc -I"C:\Program Files\MATLAB\R2019a\extern\include" /DMX_COMPAT_64 /DMATLAB_DEFAULT_RELEASE=R2017b /DUSE_MEX_CMD /DMATLAB_MEX_FILE /integer-size:32 /integer-size:64 /O2 /DNDEBUG filename
where somehow the compiler switch /integer-size:64 gets stuck in after my switch, and I get the warning,
ifort: command line warning #10121: overriding '/integer-size:32' with '/integer-size:64'
I am not finding the /integer-size switch in my mex_FORTRAN_win64.xml file, and I don't know what is causing it to get appended.
Any advise on how I could stop that switch from getting appended to the commandline, or how I could override it?
Thank you.
Siva
  8 Comments
James Tursa
James Tursa on 2 Aug 2019
Oh, you did that one yourself. Guess I was hoping for too much ...
dpb
dpb on 2 Aug 2019
Hope is about all there is for TMW ever doing anything really useful with the mex interface it seems...
I railed at them extensively 20+ years ago and all fell on totally deaf and apparently completely disinterested ears...

Sign in to comment.

Accepted Answer

Siva
Siva on 4 Aug 2019
Edited: Siva on 4 Aug 2019
This is what I ended up doing.
  1. Following https://www.mathworks.com/help/matlab/matlab_external/using-mex-script-options-to-custom-build.html, mex -v -n filename
  2. Get the list of command lines
  3. Make a batch file or makefile, adding/deleting compiler switches
Although not as convenient as simply being able to use mex in the MATLAB environment, this seems to give the necessary flexibility. Perhaps this is the intention of Mathworks.
This is simple enough, but just wanted to post it as an accepted answer to close this question.
Thank you all for your input.
Siva

More Answers (0)

Categories

Find more on MATLAB Compiler 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!