Matlab 2017a 无法识别编译器(使用 mex 时出错,未找到支持的编译器或 SDK)
Posted
技术标签:
【中文标题】Matlab 2017a 无法识别编译器(使用 mex 时出错,未找到支持的编译器或 SDK)【英文标题】:Matlab 2017a not recognizing compiler (Error using mex No supported compiler or SDK was found) 【发布时间】:2018-05-24 23:48:36 【问题描述】:我正在尝试从 fileexchange 编译一些 .cpp
文件。我已经按照here 的指示安装了 Microsoft Visual Studio 2017(所以使用实际的 C++ 编译器)。
这些组件已安装:
当我运行 mex setup -v
时,我得到的输出似乎表明找到了一些东西(在此文本之前有几行说“正在寻找编译器”...“否”):
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 14.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\8.1\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 14.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 14.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 14.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 14.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 14.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 14.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\').
... Looking for environment variable 'VS140COMNTOOLS' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2015 Professional (C)'.
... Looking for compiler 'Microsoft Visual C++ 2017 (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Community').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
Did not find installed compiler 'Microsoft Visual C++ 2017 (C)'.
请注意,有几行以“yes”结尾,它会在其中找到 Visual Studio 使用的目录。但是它以这个错误结束,表明没有找到编译器:
Error using mex
No supported compiler or SDK was found.
显然有两个错误与此相关(1、2),我应用了这些修复。但是我仍然得到同样的错误。如何让 matlab 识别编译器?!这太让人抓狂了。
windows 10、matlab 2017a和visual studio 2017社区出现这个问题,根据here应该是兼容的。有人知道如何让它工作吗?
在几个堆栈交换和 matlab 论坛上都有很多关于此的问题。如上所述,所有解决方案都需要检查兼容性或应用错误修复。那些东西我已经试过了,所以我现在在这里问。
【问题讨论】:
如果你投反对票,请解释 看来您需要 Windows 10 SDK。它应该是安装程序中的一个选项。 天哪,听起来很合乎逻辑。现在修改安装。感谢您指出这一点。 您链接的编译器支持页面说 2017a 没有对 Visual Studio 2017 的开箱即用支持,但提供 a link for a patch that adds support 【参考方案1】:好的,答案是安装这两个 Visual Studio 组件:
Windows 10 SDK(需要获取与您的 windows 匹配的版本!)
VC++ 2017 v141 工具
除了应用此错误修复:
https://nl.mathworks.com/support/bugreports/1487958很难找到这些信息,希望这对人们有所帮助。
【讨论】:
以上是关于Matlab 2017a 无法识别编译器(使用 mex 时出错,未找到支持的编译器或 SDK)的主要内容,如果未能解决你的问题,请参考以下文章