I compile C-Mex files with the Windows SDK7.1 compilers. Some C-Mex functions profit from the optimization flags "/GL /fp:fast", some other functions don't.
In e.g. Matlab <= R2011b I've created 2 different mexopts.bat files, one with these flags and the other without. Then
mex -f mexopts_Fast.bat ....
is used for compiling with these flags.
After upgrading to R2015b I find in the docs:
Do Not Use mex -f optionsfile Syntax
The mex command -f option to specify a build configuration file
will be removed in a future release.
How can I control the compiler's optimizations flags without using the -f syntax? I did not find a method to provide them as arguments for the mex command.

 採用された回答

James Tursa
James Tursa 2015 年 12 月 7 日

1 投票

Maybe try some variant of the following:
filename = your source code file name
compiler_option = '/GL /fp:fast';
mex(filename,['COMPFLAGS="$COMPFLAGS ' compiler_option '"']);

1 件のコメント

Jan
Jan 2015 年 12 月 27 日
What a pitty that mex.getCompilerConfigurations('c') does not offer a method to add an optimitzation flag dynamically.

サインインしてコメントする。

その他の回答 (1 件)

JzHartmut
JzHartmut 2017 年 10 月 18 日

1 投票

See Mathworks help mex You can write in a matlab script line:
mex -g COMPFLAGS='$COMPFLAGS /TP /EHa' ...
files etc.
The COMPFLAGS variable is enhanced. It is used for the installed compiler. In this case that are options for Microsoft Visual Studio.

4 件のコメント

Royi Avital
Royi Avital 2020 年 3 月 10 日
Pay attention that for Windows you need to use mex -g COMPFLAGS="$COMPFLAGS /TP /EHa" ....
Namely use " instead of '.
Cris Luengo
Cris Luengo 2021 年 11 月 19 日
The comment above is only true for the Windows command prompt. If you call mex from within MATLAB, use the sinlge quotes, also on Windows.
Yavuzhan Erdem
Yavuzhan Erdem 2023 年 9 月 19 日
Can I add the flag to visual studio sfun project ? I am using rtwbuild function and the system is consisting of many subsystems.
Hartmut Schorrig
Hartmut Schorrig 2023 年 9 月 19 日
I think using a Visual Studio Project is not in focus, may be not possible. The mex line calls the compiler itself as internal command line. The options after -g are forwarded to the compiler call. Get your own experience.
I don't know yet whether and where the effective called compiler command can be monitored to check what's exact happen. But that will be helpfully.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Troubleshooting in MATLAB Compiler SDK についてさらに検索

質問済み:

Jan
2015 年 12 月 6 日

コメント済み:

2023 年 9 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by