フィルターのクリア

MEX: How to modify xml file for unsupported compiler?

45 ビュー (過去 30 日間)
Bruno Luong
Bruno Luong 2020 年 12 月 4 日
コメント済み: Michal 2021 年 6 月 25 日
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?

採用された回答

sjhstone
sjhstone 2021 年 3 月 21 日
編集済み: sjhstone 2021 年 3 月 21 日
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 件のコメント
Jason Nicholson
Jason Nicholson 2021 年 6 月 6 日
Very helpful. I used this to get Intel Fortran 2021.2.0 with Visual Studio 2017 working. Thank you so much!
Michal
Michal 2021 年 6 月 25 日
Thanks, very helpful!
I hope that next version R2021b will be compatible with oneAPI compilers.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by