我想对 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 命令窗口中写下
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 类型应该做什么?
thanks
我看到两个问题:
- 你不需要包括
<matrix.h>
, <matrix.h>
包含在里面<mex.h>
. Try: include "mex.h"
代替<mex.h>
,并删除include <matrix.h>
.
-
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 https://www.mathworks.com/matlabcentral/newsreader/view_thread/297616
请考虑:我无法完全验证以下说明,因为我没有 Matlab R2007b:
分步说明:
- Go to https://www.mathworks.com/matlabcentral/fileexchange/18508-microsoft-visual-studio-2008-mex-and-mbuild-setup-files https://www.mathworks.com/matlabcentral/fileexchange/18508-microsoft-visual-studio-2008-mex-and-mbuild-setup-files
- 下载 zip 文件 VS2008Matlab.zip(按页面右上角的“下载 zip”蓝色按钮)。
- 提取 zip 文件。
- 将文件夹内容 VS2008MATLABMexCompilerFilesX64 复制到:
C:\Program Files\MATALB\R2007b\bin\win64\mexopts
(假设您的版本在默认安装文件夹中是 64 位)。
- 将文件夹内容 VS2008MATLABMBuildCompilerFilesX64 复制到:
C:\Program Files\MATALB\R2007b\bin\win64\msbuildopts
- Execute
mex -setup
,并验证 Visual Studio 2008 是否在列表中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)