本文介绍了如何将MATLAB的mex设置指向Microsoft Windows SDK的C ++编译? (设置位置错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows Vista ,并且想使用 MATLAB 来编译 C ++ 函数。我只有 lcc编译器在系统上可以看到,当运行 mex -setup

I am on Windows Vista, and want to use MATLAB to compile C++ functions. I had only the lcc compiler on the system, as can be seen when running 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 (来自此处(Windows网站)。我运行 Windows SDK 7.1命令提示符查看它安装到的目录,并查看 C:\Program Files\Microsoft SDKs \Windows \v7.1 。然后我再次运行 mex -setup ,将编译器设置为 Microsoft Visual C ++ 2010 ,通过告诉 mex 找不到已安装的编译器,我选择 Microsoft Visual C ++ 2010 选项,然后路径默认是一个 Visual Studio ; C:\Program Files \ Microsoft Visual Studio 10.0 。我试图覆盖它,但它不工作。以下是采取的确切操作:

since lcc does not work for C++ I installed the Windows SDK 7.1 from here(windows site). I ran the Windows SDK 7.1 Command Prompt to see the directory it is installed to and see C:\Program Files\Microsoft SDKs\Windows\v7.1. I then run mex -setup again to set the compiler to Microsoft Visual C++ 2010, by telling mex to not locate the installed compilers, I choose the Microsoft Visual C++ 2010 option and then the path MATLAB looks at by default is one for Visual Studio; C:\Program Files\Microsoft Visual Studio 10.0. I try to override it, but there it does not work. Here is the exact actions taken:

>> 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 ,并且如果有一种方法可以识别此目录。我也不知道如果我给的目录的方式是正确的。我试图在目录名称周围使用单引号,唯一的变化是,它停止问我目录到visual studio是否正确,我回答 n ,只有这一点。 p>

I do not know whether the directory should be different from C:\Program Files\Microsoft SDKs\Windows\v7.1, and if there is a way to identify this directory. I also do not know if the way that I give the directory is correct. I tried using single quotes around the directory name and the only variation is the that it stops to ask me whether the directory to visual studio is correct or not, I answer n and only this is given.

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 / files上运行mex? / p>

How can I add the compiler to MATLAB to be able to run mex on C++ funcitons/files?

推荐答案

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

If you are after the quick and easy approach (and do not use 64-bit matlab) I would suggest you download a free copy of Visual Studio 2010 C++ express and use that. That way mex -setup will detect it.

这篇关于如何将MATLAB的mex设置指向Microsoft Windows SDK的C ++编译? (设置位置错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!