how to enable mex detect the C/C++ compiler (integrated in Visual Studio 2022) on older MATLAB (R2018b) ?

My matlab version is 2018b, and visual studio version is 2022.
I want matlab to detect the compiler integrated in the visual studio
(path:Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64\cl.exe)
I tried to copy and modify the associated xml file, however, I found for the newest matlab, it is only support the oneAPI.
I don't know how to modify the xml file, and I have not found something similar to solve this problem.
EDIT: I (Bruno) wrongly edit the question, sorry

5 Comments

"However, I found that for the newest matlab, it only supports the oneAPI as showned in intel_c_24_vs2022.xml."
That is not normal MATLAB always support MSVS compiler for mex AFAIK https://www.mathworks.com/support/requirements/supported-compilers.html
It cannot support OneAPI 2022 on R2018. Your observation of the rellease dates do not make sense to me, I shouldn't have any compiler post 2018 supported by R2018b. You probably working with a strange MATLAB installation.
What returns this command in your case
ver
dir([matlabroot '\bin\win64\mexopts\msvc*.xml'])
MATLAB Version: 9.5.0.944444 (R2018b)
msvc2013.xml msvc2015.xml msvc2017.xml msvcpp2013.xml msvcpp2015.xml msvcpp2017.xml
intel_c_24_vs2022.xml, this file is in the newest matlab, not in 2018b.
I just want to copy this file to current path of my older matlab, and then modify it so that matlab can detect the compiler in Visual Studio 2022.
So you should start with msvc2017.xml or msvcpp2017.xml then modify it (and NOT with intel_c_24_vs2022.xml that is for Intel 2024 OneAPI compiler integrated to 2022 MSVS user interface)
The newer MATLAB version should have these files msvc2022.xml msvcpp2022.xml for MSVS 2022 compiler, but I'm not sure about backward compatibility with MATLAB older version R2018b. You could try to copy it to [matlabroot '\bin\win64\mexopts\'] and see.
Thanks for your nice reply!
I indeed chose the wrong reference before.
Now I just copy the msvc2022.xml msvcpp2022.xml to [matlabroot '\bin\win64\mexopts\'].
Then use the command
mex -setup C
mex -setup C++
There is no need to modify the xml file, and now matlab can detect my Visual Studio compiler.
Bruno, I really appreciate for your help!

Sign in to comment.

Categories

Asked:

on 30 Sep 2024

Commented:

on 2 Oct 2024

Community Treasure Hunt

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

Start Hunting!