installed compiler not found

I have installed the MinGW-w64 compiler but I still get an error message when trying to compile a cc file:
>> mex -setup c
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
>> mex -setup c++
Error using mex
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler;
see Install MinGW-w64 Compiler. For more options, visit
>> mex 'keyInject_setFocus.cc'
Error using mex
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler;
see Install MinGW-w64 Compiler. For more options, visit
The same works fine on Matlab 2017b. Suggestions?

回答 (2 件)

Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 12 日

0 投票

Hi Raphael,
Firstly, make sure that you have installed the complete version of the MinGW compiler from the add-on section of MATLAB, as custom installations of MinGW compiler may not be compatible with MATLAB.
If this issues still persists and is only occurring after restarting MATLAB, here is a workaround.

7 件のコメント

Raphael
Raphael 2020 年 11 月 12 日
Hi Aghamarsh
I am not sure what you mean by complete vs. custom installation of the compiler. There was no such option in the Add-On Explorer. I simply clicked on Download and installed it
I ran mex -setpup -v as suggested in the workaround and got this:
.. Looking for compiler 'MinGW64 Compiler (C)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\gcc.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset' ...Yes.
Found installed compiler 'MinGW64 Compiler (C)'.
Then I ran mex -setup C++ -v and got this
... Looking for compiler 'MinGW64 Compiler (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset' ...Yes.
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset').
... Executing command 'C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++ -dumpmachine' ...No.
Did not find installed compiler 'MinGW64 Compiler (C++)'.
So the problem doesn't seem the environment variable but something else
Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 13 日
編集済み: Aghamarsh Varanasi 2020 年 11 月 13 日
Hi Raphael,
I get that you have installed MinGW support package from the add-on section of MATLAB.
I suggest you to run these commands in the windows command prompt and give the outputs so that we can try to understand the root cause of the issue. Please ensure that the MinGW installation folder is added to the windows path.
  1. g++ --version
  2. g++ -dumpmachine
  3. mex -setup cpp
Raphael
Raphael 2020 年 11 月 15 日
The MinGW installer folder was not added to the windows path and I can not add it manually (got a message error when I tried. Aslo, notcie that this location is hidden and the folder doesn't appear in the list when trying to add it to the path via the interface. But even when I did try to add it manually by writing the whole path I got an error message and could save the new path)
I also tried to run the command you suggested but got error messages:
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++ --version
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++ --version
Error: Invalid use of operator.
>> C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++ -dumpmachine
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\g++ -dumpmachine
Error: Invalid use of operator.
>> mex -setup cpp
Error using mex
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler. For more options, visit
Walter Roberson
Walter Roberson 2020 年 11 月 15 日
run the commands at the windows command prompt not the matlab command prompt.
Shashwat Singh
Shashwat Singh 2024 年 3 月 7 日
Hi @Aghamarsh Varanasi , i don't have the maintenance services enabled to my MATLAB and therefore i am not able to download it from MATLAB addon...so in this situation what can i do to use the Mex compiler.
I have Microsoft Visual C++ 2017 , but still Mex is not able to work with this.
What shall i do in this situation???
Walter Roberson
Walter Roberson 2024 年 3 月 7 日
Shashwat Singh
Shashwat Singh 2024 年 3 月 7 日
編集済み: Shashwat Singh 2024 年 3 月 7 日
Hi @Walter Roberson , first of all thanks for the quick reply.....when i am going to above link which you have mentioned, then it is downloading "mingw.mlpkginstall" and when i am double clicking on it then it is giving me below error...
Connection Error
The application could not connect to MathWorks. For more information on resolving this issue, see this Support Article.
Please help if you know the resolution

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

Raphael
Raphael 2020 年 11 月 15 日

0 投票

Oops. But now I am getting 'c:\ProgramData\...full_path ...\g++' is not recognized as an internal or external command, operable program or batch file

5 件のコメント

Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 16 日
Hi Raphael,
Make sure you have 'g++.exe' installed under "C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin" folder. If you do not find 'g++.exe', I recommend you to uninstall and re-install the MinGW support package for MATLAB from the Add-Ons Manager.
Raphael
Raphael 2020 年 11 月 16 日
you can see from this screen shot that the files are indeed there
Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 16 日
編集済み: Aghamarsh Varanasi 2020 年 11 月 16 日
Hi Raphael,
You can navigate to the folder that contains the MinGW installation and execute these commands in the "windows command prompt" and send back the output. This helps to get a understanding of the underlying issue.
Steps to execute the following commands :
  1. Open Windows command prompt, by typing 'cmd' in the windows search bar. Click enter to open the windows command prompt.
  2. Execute the command
> cd C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin
to navigate to the MinGW installation folder
3. Execute the following commands
> .\g++.exe --version
> .\g++.exe -dumpmachine
4. Run the 'mex' setup command in the same location in the windows command prompt
> mex -setup cpp
Thanks
Raphael
Raphael 2020 年 11 月 16 日
Here is the output:
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin>.\g++.exe --version
g++.exe (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin>.\g++.exe -dumpmachine
x86_64-w64-mingw32
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin>mex -setup cpp
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; visit https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html. For more options, visit https://www.mathworks.com/support/compilers.
Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 16 日
Hi Raphael,
I understand that you have installed MinGW support package for MATLAB, but are not able to setup mex.
The outputs that you for the commands also suggest the same. As I am not able to reproduce the same at my end, I suggest you contact MathWorks support to resolve the issue.
Thanks

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

製品

リリース

R2020b

質問済み:

2020 年 11 月 5 日

編集済み:

2024 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by