How can I use Microsoft Visual C++ 2010 to create MEX files with MATLAB 7.10 (R2010a)?

来源:互联网 发布:java培训一般价格 编辑:程序博客网 时间:2024/05/21 06:18

标题

How can I use Microsoft Visual C++ 2010 to create MEX files with MATLAB 7.10 (R2010a)?1

如何在MATLAB2010a中使用VS2010编译器创建(编译)MEX文件

最近在学习有关MC-BCS-SPL的算法代码,其中遇到要对C文件2进行编译的问题,但是一直编译出错。实验室同学有讲是我使用的MATLAB2010a未能支持VS2010的编译器,寻找解决方法之际发现硬盘里的“VS2010MEXSupport.zip”文件,所以就在此翻译下MathWorks Support Team给出的解决方法。

翻译

原文

The Microsoft Visual C++ 2010 compiler is not supported on the released version of MATLAB 7.10 (R2010a), but support can be added by installing a patch. To install the patch:

  1. Download the patch attached to this Solution. The patch includes files needed to support these combinations of MATLAB and Visual C++ 2010:

    • Visual C++ 2010 Professional and 64-bit MATLAB 7.10 (R2010a)

    • Visual C++ 2010 Professional and 32-bit MATLAB 7.10 (R2010a)

    • Visual C++ 2010 Express (Windows SDK 7.1 also required) and 64-bit MATLAB 7.10 (R2010a)

    • Visual C++ 2010 Express and 32-bit MATLAB 7.10 (R2010a)

  2. Launch MATLAB 7.10 (R2010a). If running on Windows Vista or Windows 7 run as administrator by right-clicking on the MATLAB shortcut and choosing “Run As Administrator”. This permits modification of files in the MATLAB installation path.

  3. Confirm that you are running MATLAB 7.10 (R2010a). You can check this using the About box available at Help->About MATLAB.

  4. Unzip the contents of the patch into your MATLAB installation using the following command on the MATLAB command window:

    unzip( path_to_zip_file, matlabroot);

This command will automatically unzipped the files in the correct folder and you do not have to worry about placing them in correct folder.

  1. Set up MEX to use Visual C++ 2010 with the command:
    mex –setup

Visual C++ 2010 should now be among the listed options.

Note that this patch will only work with MATLAB 7.10 (R2010a). Using this patch with any version of MATLAB is not supported.

Other MathWorks products such as Real-Time Workshop do not support Visual C++ 2010.

Refer to http://www.mathworks.com/support/compilers/R2010a/index.html for up-to-date information concerning supported compilers.

翻译

MATLAB7.10(R2010a)并不支持VS2010的编译器,但是可以通过安装一个补丁来完成支持。具体补丁安装方法如下:

  1. 从附上的地址下载补丁3。该补丁只针对下边版本的MATLAB及VS的结合才有效:
    VS2010专业版+64bit MATLAB7.10(R2010a)
    VS2010专业版+32bit MATLAB7.10(R2010a)
    vs2010精简版(需要安装Windows SDK 7.1)+64bit MATLAB7.10(R2010a)
    vs2010精简版(需要安装Windows SDK 7.1)+32bit MATLAB7.10(R2010a)
  2. 运行MATLAB2010(R2010a)。无论是在Vista还是Win7系统上运行,都要以右键的管理员身份打开以确保第4步的修改可以允许进行。
  3. 确定版本是否为MATLAB2010(R2010a)。可以通过菜单栏的“Help->About MATLAB”来核实。
  4. 使用如下命令把补丁(该补丁应该在当前MATLAB的工作目录下)的内容解压到MATLAB的安装路径里:
    unzip('VS2010MEXSuport.zip');

该命令会自动将补丁内容解压到MATLAB的安装路径里(而且会将32bit和64bit的同时解压进去,所以没有必要担心系统为32bit还是64bit),具体的解压路径如下:

D:\Program Files\MATLAB\R2010a\bin\win64\mexopts
D:\Program Files\MATLAB\R2010a\bin\win32\mexopts

  1. 使用如下命令设置MEX以使用VS2010
    mex -setup

VS2010必须为上边所列版本。
需要注意的是该补丁只针对MATLAB2010(R2010a)版本有效。
其他类似MathWorks的Real-Time Workshop并不支持VS2010。
可以登录http://www.mathworks.com/support/compilers/R2010a/index.html获取有关编译器支持的实时信息。

说明

1.必须以管理员身份运行MATLAB

2.确保补丁在MATLAB的当前工作目录下

参考文献


  1. 原文地址 ↩
  2. MC-BCS-SPL源代码网址 ↩
  3. 补丁下载地址 ↩
0 0
原创粉丝点击