Determining selected MEX compiler inside m-Function running in Simulink
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dan Harris
am 27 Jun. 2018
Kommentiert: Dan Harris
am 3 Jul. 2018
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!!!
0 Kommentare
Akzeptierte Antwort
Jon Lobo
am 3 Jul. 2018
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Support for MinGW-w64 C/C++ Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!