MEX: How to modify xml file for unsupported compiler?

58 views (last 30 days)
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.
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?

Accepted Answer

sjhstone on 21 Mar 2021
Edited: sjhstone on 21 Mar 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
<envVarExists name="ICPP_COMPILER20" />
<fileExists name="$$/Bin/intel64/icl.exe" />
<dirExists name="$$/../.." />
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" />
<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,
% 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.
Michal Kvasnicka
Michal Kvasnicka on 25 Jun 2021
Thanks, very helpful!
I hope that next version R2021b will be compatible with oneAPI compilers.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by