VS2008与MATLAB R2007a混合编程配置过程

系统平台:windows xp sp2, visual studio 2008 professional, matlab R2007a

首先,为了使matlab 能够找到vs2008编译器,需要下载以下一些配置文件。http://www.mathworks.com/matlabcentral/fileexchange/18508

依据下载文件中directory.txt文件中所给出的文件目录:

MATLABROOT\bin\win32\mexopts MATLABROOT\bin\win32\mbuildopts

将对应目录VS2008MATLABMexCompilerFilesX86中的6个文件拷贝到mexopts目录下;

将对应目录VS2008MATLABMBuildCompilerFilesX86中的2个文件拷贝到mbuildopts目录下。

第二步,打开matlab应用程序,运行mex -setup命令:

Please choose your compiler for building external interface (MEX) files:    Would you like mex to locate installed compilers [y]/n? n(由于本机的vs2008没有安装在系统目录下,所以不适用mex搜索编译器)

Select a compiler:  [1] Borland C++ Compiler (free command line tools) 5.5  [2] Borland C++Builder 6.0  [3] Borland C++Builder 5.0  [4] Compaq Visual Fortran 6.1  [5] Compaq Visual Fortran 6.6  [6] Intel C++ 9.1 (with Microsoft Visual C++ 2005 linker)  [7] Intel Visual Fortran 9.1 (with Microsoft Visual C++ 2005 linker)  [8] Intel Visual Fortran 9.0 (with Microsoft Visual C++ 2005 linker)  [9] Intel Visual Fortran 9.0 (with Microsoft Visual C++ .NET 2003 linker)  [10] Lcc-win32 C 2.4.1  [11] Microsoft Visual C++ 6.0  [12] Microsoft Visual C++ .NET 2003  [13] Microsoft Visual C++ 2005  [14] Microsoft Visual C++ 2005 Express Edition  [15] Microsoft Visual C++ 2008  [16] Microsoft Visual C++ 2008 Express Edition  [17] Open WATCOM C++ 1.3    [0] None 

选择编号为15的Microsoft Visual C++ 2008编译器。

紧接着会给出vs2008的默认路径:c:\program files\microsoft visual studio 9.0

Use c:\program files\microsoft visual studio 9.0 [y]/n? n (手动设置vs2008的路径)

Please enter the location of your compiler:。。。。(在此输入vs2008的安装路径,如E:\programs\VS2008)

然后确认编译器的路径是否正确。

第三步,matlab提示编译器用到了windows 平台SDK库,并且没有找到MSSdk环境变量:

手动添加系统环境变量:MSSdk。

变量名:MSSdk;

变量值:C:\Program Files\Microsoft SDKs\Windows\v6.0A

设置完成该环境变量后,重启matlab,再次输入mex -setup,手动选择编译器类型[15] Microsoft Visual C++ 2008,

手动设置vs2008安装路径,matlab提示无错误,混合编译环境变配置完成。

注意:由于该混合编译的方式用到了vs2008的运行时库,所以在程序发布时,需要将vs2008的运行时库一并包含在内。

可以通过在文件msvc90opts.stp中修改my $default_location的值为:my $default_location = "E:\\programs\\VS2008";

来给出vs2008的安装目录,省去每次手动输入路径时的麻烦

posted @ 2014-03-06 19:52  xiaobiexi  阅读(767)  评论(0编辑  收藏  举报