如何将MATLAB的mex安装程序引导到用于C ++编译的Microsoft Windows SDK? (设置位置错误)

我在Windows Vista ,想用MATLAB编译C++函数。 我只有系统上的lcc compiler ,如运行mex -setup时可以看到的那样:

 mex -setup Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www.mathworks.com/support/compilers/R2011a/win32.html Please choose your compiler for building MEX-files: Would you like mex to locate installed compilers [y]/n? y Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011a\sys\lcc [0] None Compiler: 

因为LCC不适用于C ++我从这里安装Windows SDK 7.1 (Windows站点) 。 我运行Windows SDK 7.1 Command Prompt以查看它安装到的目录,并查看C:\Program Files\Microsoft SDKs\Windows\v7.1 。 然后,再次运行mex -setup ,将编译器设置为Microsoft Visual C++ 2010 ,通过告诉mex找不到已安装的编译器,我selectMicrosoft Visual C++ 2010选项,然后MATLAB默认查找的path是Visual Studio ; C:\Program Files\Microsoft Visual Studio 10.0 。 我尝试重写它,但是它不起作用。 以下是采取的具体措施:

 >> mex -setup Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www.mathworks.com/support/compilers/R2011a/win32.html Please choose your compiler for building MEX-files: Would you like mex to locate installed compilers [y]/n? n Select a compiler: [1] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [2] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [3] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) [4] Lcc-win32 C 2.4.1 [5] Microsoft Visual C++ 6.0 [6] Microsoft Visual C++ 2005 SP1 [7] Microsoft Visual C++ 2008 SP1 [8] Microsoft Visual C++ 2010 [9] Microsoft Visual C++ 2010 Express [10] Open WATCOM C++ [0] None Compiler: 8 Warning: The default location for Microsoft Visual C++ 2010 compiler is: "C:\Program Files\Microsoft Visual Studio 10.0" but either that directory does not exist or the configuration is invalid. Use C:\Program Files\Microsoft Visual Studio 10.0 anyway [y]/n? n Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 10.0] C:\Program Files\Microsoft SDKs\Windows\v7.1 Please verify your choices: Compiler: Microsoft Visual C++ 2010 Location: C:\Program Files\Microsoft Visual Studio 10.0 Are these correct [y]/n? ***************************************************************************** Error: Microsoft Visual C++ 2010 requires the Microsoft Windows Software Development Kit (SDK), but the SDK cannot be found. Examine your Microsoft Visual C++ 2010 installation. ***************************************************************************** ??? Error using ==> mex at 208 Unable to complete successfully. 

我不知道该目录是否应该与C:\Program Files\Microsoft SDKs\Windows\v7.1 ,以及是否有方法来识别此目录。 我也不知道我给目录的方式是否正确。 我尝试在目录名称周围使用单引号,唯一的变化就是停下来询问我的视觉工作室目录是否正确,我回答n ,只给出这个。

 Compiler: Microsoft Visual C++ 2010 Location: C:\Program Files\Microsoft Visual Studio 10.0 Are these correct [y]/n? n mex: No compiler selected. No action taken. 

如何将编译器添加到MATLAB,以便能够在C ++ funcitons /文件上运行mex?

如果您使用的是简单快捷的方法(并且不使用64位的matlab),我建议您下载Visual Studio 2010 C ++ express的免费副本并使用它。 这样mex -setup会检测到它。