MEX: How to modify xml file for unsupported compiler?

39 visualizaciones (últimos 30 días)
Bruno Luong
Bruno Luong el 4 de Dic. de 2020
Comentada: Michal el 25 de Jun. de 2021
Context:
I download the intel oneAPI C++ compiler.
The C compiler is not supported by Matlab R2020b and I try to design the xml file that can detect this compiler.
Disclaim
I know next to nothing about xml file and how it's use by MATLAB mex
First attempt
I copy the stock file intel_c_20_vs2019.xml from bin\win64\mexopts folder to intel_c_21_vs2019.xml and modify it, and
>> mex -setup:intel_c_21_vs2019.xml C++
Error using mex
MEX cannot use compiler 'Intel Parallel Studio XE 2021 with Microsoft Visual Studio 2019 (C)' because that compiler is not found.
Take a closer look at the xml file, I see it use the parameter $CROOT to design where the path in several places. But I cannot see where it is defined.
My question is can I define it (in the xml file)?and How?

Respuesta aceptada

sjhstone
sjhstone el 21 de Mzo. de 2021
Editada: sjhstone el 21 de Mzo. de 2021
Hello, if you just want to modify how $CROOT variable is captured, please search for <locationFinder> in your XML config file, and you may immediately see it is written as something like this
<and>
<or>
<envVarExists name="ICPP_COMPILER20" />
</or>
<fileExists name="$$/Bin/intel64/icl.exe" />
<dirExists name="$$/../.." />
</and>
Now according to this XML, and my installation of OneAPI is placing icl.exe to %ONEAPI_ROOT%\compiler\2021.1.1\windows\bin\intel64\
First, we make a copy of the file to something that looks right, say intel_one_classical_c_vs2019.xml.
Then, change Name and ShortName fields to avoid colliison.
Finally, just modify the ICPP_COMPILER20 to INTELONEAPI_CLASSIC_ICC (or any name you like without overriding existing environment variable) and modify
<fileExists name="$$/Bin/intel64/icl.exe" />
into
<fileExists name="$$/bin/intel64/icl.exe" />
because the path is case-sensitive. Now, XML works have been done. Then let's go to matlab command prompt,
cd(fullfile(matlabroot,'bin','win64','mexopts'));
% in case system-level environment variable has not been populated to
% MATLAB, you can manually specify the value of environment variable
setenv('INTELONEAPI_CLASSIC_ICC', '{oneAPI_Installation}\compiler\2021.1.1\windows\bin\intel64\');
mex -setup:intel_one_classical_c_vs2019.xml -v c
The -v flag helps you to detect problem in a more detailed way.
If your MEX function needs math.h or some libraries, you may have to further modify the last few lines in <env> tag so library files can be properly found.
If you also want to do this for C++ MEX, just do something similar.
  3 comentarios
Jason Nicholson
Jason Nicholson el 6 de Jun. de 2021
Very helpful. I used this to get Intel Fortran 2021.2.0 with Visual Studio 2017 working. Thank you so much!
Michal
Michal el 25 de Jun. de 2021
Thanks, very helpful!
I hope that next version R2021b will be compatible with oneAPI compilers.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by