フィルターのクリア

How can I change default c++ compiler in MATLAB 2017b ?

15 ビュー (過去 30 日間)
Diana Becea
Diana Becea 2018 年 10 月 26 日
コメント済み: Diana Becea 2018 年 10 月 30 日
So I have MATLAB2017b version. I want to use Matlab in combination with TwinCat to control some motors and sensors. I need Visual Studio 20XX to run the program.
I have installed VisualStudio 2013 professional and other versions of it, and also Visual Studio 2017. When I run "mex -setup" in Matlab, its says "MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.". I cannot see any other languages from where I could choose except the default "MinGW64". I have looked at the compatibility issues as well and this version of Matlab should run perfectly with VisualStudio 2013 professional or a higher version. I have tried to install different versions and it still does not see it.
Can anyone offer a solution? I have been searching for days already and nothing has worked (including some patches I have found online).
  4 件のコメント
Walter Roberson
Walter Roberson 2018 年 10 月 29 日
Try unsetting the environment variable MW_MINGW64_LOC
Diana Becea
Diana Becea 2018 年 10 月 29 日
編集済み: Walter Roberson 2018 年 10 月 29 日
I did this..
Now for "mex -setup"
I have this:
"Error using mex
No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler;
see Install MinGW-w64 Compiler. For more options, visit http://www.mathworks.com/support/compilers."
and for : "mex -v -setup c++"
I have this:
"Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...No.
Did not find installed compiler 'MinGW64 Compiler (C++)'.
Error using mex
No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler;
see Install MinGW-w64 Compiler. For more options, visit http://www.mathworks.com/support/compilers."
.....But it still does not se the VisualStudio2013

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

採用された回答

Kenny Shu
Kenny Shu 2018 年 10 月 29 日
The output of "mex -setup -v" should show the paths and registry settings MATLAB checks to find supported compilers.
The part of the output between "... Looking for compiler 'Microsoft Visual C++ 2013 Professional' ..." and "Did not find installed compiler 'Microsoft Visual C++ 2013 Professional'." should reveal why MATLAB is not detecting the VS2013 Compiler.
If this part is missing, then MATLAB may not be searching for the Visual Studio 2013 C++ Compiler.
Check that "msvc2013.xml" and "msvcpp2013.xml" exist in "MATLABROOT\bin\win64\mexopts" and that these files can be read by MATLAB:
f1 = fopen(fullfile(matlabroot, 'bin', 'win64', 'mexopts', 'msvcpp2013.xml'));
f2 = fopen(fullfile(matlabroot, 'bin', 'win64', 'mexopts', 'msvc2013.xml'));
l1 = textscan(f1, '%s', 1, 'delimiter', '\n', 'headerlines',2);
l2 = textscan(f2, '%s', 1, 'delimiter', '\n', 'headerlines',2);
l1{:}
l2{:}
If these files are missing, a re-install should restore them. If these files exist but cannot be accessed, check that MATLAB is running with administrative privileges.
  1 件のコメント
Diana Becea
Diana Becea 2018 年 10 月 30 日
Thank you, Sir! You have saved me a lot of trouble! The files were missing. I just coppied them in the folder from another laptop!

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

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2018 年 10 月 29 日
It might not correctly detect if you install MSVS on drive other than C:
  1 件のコメント
Diana Becea
Diana Becea 2018 年 10 月 29 日
I only have one partition on my laptop

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

Community Treasure Hunt

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

Start Hunting!

Translated by