c++ - Microsoft Visual C++ 2008 和 R2007b 的 Mex 类型

标签 c++ matlab mex

我想为 vs2008 和 matlab2007b 使用 mex 类型。我尝试了下面的代码。

#include<iostream>
#include <matrix.h>
#include<mex.h>
using namespace std;
void hello(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  mexPrintf("Hello World!\n");
}

得到这个错误

'matrix.h': No such file or directory

我在下面用 matlab commond win 写了

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: 
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2007b\sys\lcc 

[0] None 

Compiler: 

那么使用 mex 类型应该怎么做呢?

谢谢

最佳答案

我看到两个问题:

  1. 您不需要包含 <matrix.h> , <matrix.h>包含在 <mex.h> 中.尝试:include "mex.h"而不是 <mex.h> , 并删除 include <matrix.h> .
  2. mex -setup找不到您的 Microsoft Visual C++ 2008 编译器。

选择菜单应该如下所示:

Please choose your compiler for building external interface (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\R2007b\sys\lcc
[2] Microsoft Visual C++ 2008
[0] None

由于Visual 2008比Matlab R2007b更新,Matlab无法自动定位Visual 2008。

有一种方法可以手动添加。
引用这里:https://www.mathworks.com/matlabcentral/newsreader/view_thread/297616

请考虑:我无法完全验证以下说明,因为我没有 Matlab R2007b:

分步说明:

  1. 转到 https://www.mathworks.com/matlabcentral/fileexchange/18508-microsoft-visual-studio-2008-mex-and-mbuild-setup-files
  2. 下载 zip 文件 VS2008Matlab.zip(按页面右上角的“下载 zip”蓝色按钮)。
  3. 解压缩 zip 文件。
  4. 将文件夹内容 VS2008MATLABMexCompilerFilesX64 复制到:C:\Program Files\MATALB\R2007b\bin\win64\mexopts (假设您的版本在默认安装文件夹中为 64 位)。
  5. 将文件夹内容 VS2008MATLABMBuildCompilerFilesX64 复制到:C:\Program Files\MATALB\R2007b\bin\win64\msbuildopts
  6. 执行mex -setup ,并验证 Visual Studio 2008 在列表中。

关于c++ - Microsoft Visual C++ 2008 和 R2007b 的 Mex 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38583411/

相关文章:

c++ - 编译器是否检测到错误的共享变量?

matlab - 如何使用 MATLAB 计算二值图像中白色像素的数量?

matlab - 如何在matlab中将向量添加到矩阵?

c++ - 使用 Octave 构建 Mex 文件(包装器问题)

c - 如何在引入 mxIsScalar 之前检查变量是标量还是数组?

c++ - WIC WINCODEC_ERR_BADHEADER 仅适用于 JPEG 图像

c++ - 如何从具有 userID 和 pageID 的大型日志文件中查找最常访问的 3 个网页序列

c++ - 模板特化方法

matlab - 如何在 MATLAB 中高效实现 Maxpooling?

matlab - 使用 mex 在 MATLAB 中找不到 C++ 编译器