Edit mex configuration programmatically

3 views (last 30 days)
Jim Hokanson
Jim Hokanson on 18 Jun 2014
Answered: Jim Hokanson on 18 Jun 2014
Hi all,
I'd like to be able to edit the mex configuration programatically. There are some recent changes to the configuration options, having moved from mexopts.bat (windows) to xml files. For now let's assume I'm using the newer approach. You can query information regarding the compiler configuration using:
mex.getCompilerConfigurations
There doesn't seem to be a way to use this information to change anything.
My use case is the following. I'd like to use the flag /MDt instead of /MD for Visual Studio 2012. If I do:
COMPFLAGS="$COMPFLAGS /MDt"
The /MD flag that is present overrides the /MDt directive I passed in. Thus it seems that I need to actually remove the /MD flag in the options file.
Any suggestions?
Thanks, Jim
  1 Comment
James Tursa
James Tursa on 18 Jun 2014
Edited: James Tursa on 18 Jun 2014
In the past, I have actually opened up the old mexopts.bat file and copied it to a new file with modifications, then used that new file. I don't know how to do something similar under the new scheme where there is apparently no mexopts.bat file to work with.

Sign in to comment.

Answers (2)

James Tursa
James Tursa on 18 Jun 2014
Can you go into the mexopts directory, copy all of the setup files for the compiler you are using into new files with slightly different names, then edit those new files to get the /MDt option you want? Maybe that will let the mex command see that to use. Under the new scheme, I don't know how to coax the mex command to use that option set though. Maybe make it alphabetically first in the file listing? I don't have a recent version of MATLAB to experiment with for this unfortunately. Maybe you will have to simply edit the existing mexopts files instead of creating copies.

Jim Hokanson
Jim Hokanson on 18 Jun 2014
So the current solution I have in mind is roughly the following:
  1. back up the default file
  2. replace the default with my file
  3. execute the code
  4. restore the default file
I was hoping there was a better more obvious way of doing this, but perhaps not :/

Categories

Find more on Introduction to Installation and Licensing 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!