Determining selected MEX compiler inside m-Function running in Simulink

1 回表示 (過去 30 日間)
Dan Harris
Dan Harris 2018 年 6 月 27 日
コメント済み: Dan Harris 2018 年 7 月 3 日
I am attempting to determine the active MEX compiler inside a MATLAB function that is called by a MATLAB function block in Simulink. I need to do this because this function also calls an external library and depending on what compiler is selected, my function needs to source the correct version of the shared library for use. I have tried the following in my code:
coder.extrinsic('mex.getCompilerConfigurations');
comp_C.ShortName = ' ';
comp_CPP.ShortName = ' ';
comp_C_info = ' ';
comp_CPP_info = ' ';
comp_C=coder.const(mex.getCompilerConfigurations('C','Selected'));
comp_CPP=coder.const(mex.getCompilerConfigurations('C++','Selected'));
comp_C_info=comp_C.ShortName;
comp_CPP_info=comp_CPP.ShortName;
if contains(comp_C_info,'mingw64') && ...
contains(comp_CPP_info,'mingw64-g++')
comp = 1;%minGW
elseif contains(comp_C_info,'MSVC') && ...
contains(comp_CPP_info,'MSVCPP')
comp = 2;%Visual Studio
end
The error I receive back is:
This 'mex.CompilerConfiguration' constant could not be eliminated.
Function 'foo.m' (#65.46734.46781), line 924, column 26:
"mex.getCompilerConfigurations('C++','Selected')"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
This 'mex.CompilerConfiguration' constant could not be eliminated.
Function 'foo.m' (#65.46661.46706), line 923, column 24:
"mex.getCompilerConfigurations('C','Selected')"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
If my method is correct, how do I correct this error? If not, what is the better way to identify the active MEX compiler, in this context?
Thanks!!!

採用された回答

Jon Lobo
Jon Lobo 2018 年 7 月 3 日
Hi Dan,
I recommend putting this in a model callback rather than in a MATLAB function block. This can execute before the start of your model is in a good spot to figure out which compilers are available rather than in the simulation phase.

その他の回答 (0 件)

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by