【问题标题】:matlab compiler installation problemsmatlab编译器安装问题
【发布时间】:2013-08-26 15:37:54
【问题描述】:

我正在尝试在 MATLAB 上运行编译器,但事情并没有按预期进行。如何正确安装 MATLAB 以及如何检查到底出了什么问题。我有 MATLAB r2013a 版本。

我做了如下:

  1. 我已经从 here 下载了 SDK 7.1 文件

    • 工具的目标文件夹:C:\Program Files\Microsoft SDKs\Windows\v7.1
    • 样本的目标文件夹:C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples
  2. 我已将编译器目录添加到路径环境中

    • 控制面板 -> 系统 -> “高级” -> “环境变量”。
    • 名为“MSSdk”的新系统变量。
    • 此变量的值:C:\Program Files\Microsoft SDKs\Windows\v7.1
    • 关闭并重新启动 MATLAB

接下来我尝试使用以下步骤并使用mex -setup 命令配置 MATLAB:

  • 通过“您希望 mex 找到已安装的编译器”选择 n 后,我得到了一个编译器列表(请参阅上面的评论)。我选择了17

    [1] Intel C++ 13.0 (with Microsoft Software Development Kit (SDK) linker) 
    [2] Intel C++ 13.0 (with Microsoft Visual C++ 2010 linker) 
    [3] Intel C++ 13.0 (with Microsoft Visual C++ 2012 linker) 
    [4] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) 
    [5] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
    [6] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) 
    [7] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
    [8] Intel Visual Fortran 13 (with Microsoft Software Development Kit (SDK) linker) 
    [9] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2010 linker) 
    [10] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2012 linker) 
    [11] Intel Visual Fortran 12 (with Microsoft Software Development Kit (SDK) linker) 
    [12] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
    [13] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker) 
    [14] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) 
    [15] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
    [16] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) 
    [17] Microsoft Software Development Kit (SDK) 7.1 
    [18] Microsoft Visual C++ 2005 SP1 
    [19] Microsoft Visual C++ 2008 SP1 
    [20] Microsoft Visual C++ 2010 
    [21] Microsoft Visual C++ 2012 
    
  • 以下警告:

    The default location for Microsoft Software Development Kit (SDK) compiler is:
    "C:\Program Files (x86)\Microsoft Visual Studio 10.0"
    but either that directory does not exist or the configuration is invalid.
    
  • 问题:

    Use C:\Program Files (x86)\Microsoft Visual Studio 10.0 anyway [y]/n?
    
  • 我选择了n 并将C:\Program Files\Microsoft SDKs\Windows\v7.1 作为我的新目录

这里是它停止的地方:

Error: The Microsoft Windows Software Development Kit (SDK) installation is 
         incomplete.  Please be sure that the .NET Framework is installed 
         correctly before attempting to reinstall the SDK. 

编辑:

我的第二次尝试如下:

  • 我删除了所有 Visual Basic 文件(通过删除程序中列为 Visual Basic 的所有项目)
  • 我再次重新安装了 SDK 文件,但未检查 Visual c++ 编译器和 Microsoft Visual c++
  • 将来自 Microsoft 的 patch 应用到 SDK 7.1 安装(如果尚未完成)
  • 重新安装了 Visual C++ 2010 Redistributable 包:x86 和 x64
  • 在 MATLAB 中我再次使用了mex -setup

发生了以下事情:

  • 我在提问后选择了y

    Would you like mex to locate installed compilers [y]/n?
    [1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0 
    
  • 我选择了1

  • 然后在询问这是否正确后,根据选择 yn 得到以下 2 个输出

我选择了 n:

mex: No compiler selected. No action taken. 

************************************************************************** 
  Warning: The MATLAB C and Fortran API has changed to support MATLAB 
           variables with more than 2^32-1 elements.  In the near future 
           you will be required to update your code to utilize the new 
           API. You can find more information about this at: 
           httpx://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html  
           Building with the -largeArrayDims option enables the new API. 
************************************************************************** 


Error using mex (line 206)
Unable to complete successfully.

我选择了 y:

*************************************************************************** 
  Warning: MEX-files generated using Microsoft Windows Software Development 
           Kit (SDK) require that Microsoft Visual Studio 2010 run-time  
           libraries be available on the computer they are run on. 
           If you plan to redistribute your MEX-files to other MATLAB 
           users, be sure that they have the run-time libraries. 
*************************************************************************** 


Trying to update options file: C:\Users\Gebruiker\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat 
From template:              C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\mssdk71opts.bat 

Done . . . 

************************************************************************** 
  Warning: The MATLAB C and Fortran API has changed to support MATLAB 
           variables with more than 2^32-1 elements.  In the near future 
           you will be required to update your code to utilize the new 
           API. You can find more information about this at: 
           httpx://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html  
           Building with the -largeArrayDims option enables the new API. 
************************************************************************** 


Error using mex (line 206)
Unable to complete successfully.

编辑:

我发现我面临的问题似乎与 Perl 的问题无关。片刻之后,会出现以下注释:

"Perl Command Line Interpreter has stopped working"

这个post 有类似的问题。我做了如下。我下载了Strawberry Perl 并做了几次替换。

  • 替换所有 exe 文件
  • 替换 perl .exe 文件

    在这两种情况下都会出现以下情况

    Can't locate shellwords.pl in @INC (@INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib . C:\PROGRA~1\MATLAB\R2013a\bin\) at C:\Program Files\MATLAB\R2013a\bin\mex.pl line 159. 
    Error using mex (line 206)
    Unable to complete successfully.
    
  • 用 Strawberry Perl 中的 bin 文件替换 bin 文件

    '"C:\Program Files\MATLAB\R2013a\sys\perl\win32\bin\perl.exe"' is not recognized as an internal or external command, 
    operable program or batch file. 
    Error using mex (line 206)
    Unable to complete successfully.
    

但是这似乎不起作用。所以这似乎是两件事:

  • 那样不行(只有一个人声称他已经这样做了)
  • 我将 MATLAB 中的错误文件替换为 Strawberry Perl 中的文件。

编辑:按照建议,我将 matlab 中的 perl 恢复为原始版本。


我已经下载了 Visual Studio Express 2012 并尝试完成这项工作。问题还是一样的。

【问题讨论】:

  • 为什么人们不赞成这个灵魂?这个问题显示了搜索工作,它有用且清晰。它来自一个新用户,他没有问“如何在我的计算机上正确安装 mex”,而是向我们展示了他所有的尝试轨迹。如我所见,我们想要的正是这类问题……
  • 如果你必须在mex文件中编译C/C++代码宿主,你可以使用Compiling mex files with Visual Studio中的过程吗?
  • 不,我认为您不应该混淆 MATLAB 附带的 Perl 版本……它甚至不是完整的 Perl 安装。我建议你恢复你替换的所有文件
  • 当被问及 MATLAB 是否应该找到支持的编译器时,您也不应该使用 say no。如果自动检测不起作用,说明你没有正确安装需求
  • Perl 版本恢复到以前的版本。所以回到第一方:-)。我已经下载了 Visual Studio Express 2012 版本。但是,如果我执行 mex -setup 然后是的,它不会出现在我选择的安装程序之间

标签: matlab compiler-construction 64-bit mex winapi


【解决方案1】:

所以,我首先检查的是 matlab 支持的编译器页面:
http://www.mathworks.com/support/compilers/R2013a/index.html

我原以为 SDK 7.1 将不受支持,但显然它支持,甚至在列表的顶部。但是,您的一个错误是抱怨 .NET,在那个 MATLAB 页面上,有一条关于 SDK 7.1 需要 .NET Framework 4.0 的警告(在表格中,位于 SDK 7.1 单元格的底部。)

每当我在 Windows 中完成此操作时,我总是只使用 Visual Studio 编译器。我建议先尝试一下,因为我不记得这个 mex 设置过程需要很长时间(在成功/失败之前)。

【讨论】:

  • Visual Studio Professional 当然拥有所需的一切。如果您没有,Express 版本本身不足以进行 64 位编译,您还必须获得 Windows SDK(均可免费下载)...
  • 我没有专业版。我有 SDK 和 Visual Basic,你知道在哪里可以找到使它们在 matlab 中协同工作所需的信息吗?
  • 已安装 Visual Professional 2012 试用版,目前情况开始看起来不错。感谢我收到的所有帮助。
【解决方案2】:

在安装 Windows SDK 之前,请确保您拥有 .NET Framework 4.0。请注意,Windows 7 仅附带 .NET Framework 3.5,这还不够。

您可能会发现以下说明很有用:

How do I install Microsoft Windows SDK 7.1?

【讨论】:

  • 感谢您的提示。我查看了我的注册表,似乎已安装 NET Framework 4.0。
猜你喜欢
  • 1970-01-01
  • 2020-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多