首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置mex以使用Visual Studio 2010编译器

设置mex以使用Visual Studio 2010编译器
EN

Stack Overflow用户
提问于 2010-11-02 21:26:50
回答 3查看 32.7K关注 0票数 10

我已经安装了Visual Studio 2010。但是,MATLAB找不到编译器。

代码语言:javascript
复制
>> mex -setup
Please choose your compiler for building external interface (MEX) files: 

Would you like mex to locate installed compilers [y]/n? y

Select a compiler: 

[0] None 

Compiler:

如果我对这个问题回答n,我会得到以下结果

代码语言:javascript
复制
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 C++ 9.1 (with Microsoft Visual C++ 2005 SP1 linker) 
[3] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
[4] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) 
[5] Intel Visual Fortran 10.1 (with Microsoft Visual C++ 2005 SP1 linker) 
[6] Microsoft Visual C++ 2005 SP1 
[7] Microsoft Visual C++ 2008 Express 
[8] Microsoft Visual C++ 2008 SP1 

[0] None 

Compiler: 8

The default location for Microsoft Visual C++ 2008 SP1 compilers is C:\Program Files (x86)\Microsoft Visual Studio 9.0, 
but that directory does not exist on this machine.  

Use C:\Program Files (x86)\Microsoft Visual Studio 9.0 anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files (x86)\Microsoft Visual Studio 9.0] 

编译c++代码使其在MATLAB中可用的最简单方法是什么?安装Visual C++ 2008?oO

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2010-11-03 02:47:13

这取决于您使用的MATLAB版本。R2010b开箱即可支持VS2010。如果您使用的是R2010a,可以使用以下补丁:

  • Update From the World of MEX: Visual Studio 2010 Support
  • How can I use Microsoft Visual C++ 2010 to create MEX files with MATLAB 7.10 (R2010a)?
票数 7
EN

Stack Overflow用户

发布于 2010-11-02 21:34:08

有超过1种解决问题的方法,但只有一种涉及金钱:)

  1. 购买/升级到新的Matlab版本(R2010b可以识别并与VS2010一起工作)。
  2. 您不必安装完整的VS2008包,旧的Windows SDK v7.0就足够了。一旦安装,matlab应该会认识到,当你做你自己建议的mbuild -setup.
  3. As时,安装VS2008。

供将来参考:http://www.mathworks.com/support/compilers/R2010b/index.html

票数 2
EN

Stack Overflow用户

发布于 2010-11-03 01:36:14

您还可以在不使用mex的情况下使c++代码可用于Matlab。Matlab能够加载外部DLL并调用它们的函数。因此,您可以将代码包装到DLL中,并完全绕过mex。

一般来说,我发现这是从matlab中调用C或C++代码的一种更简单的方法。缺点是您不会拥有mex提供的用于操作matlab数据结构的所有工具。你仍然可以来回传递数据,有些事情会更麻烦,比如在C中分配一个数组,然后把它的所有权交给matlab。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4078094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档