问题描述
我想对vs2008和matlab2007b使用mex类型.我在下面尝试了代码.
i want to use mex type for vs2008 and matlab2007b.i tried code below.
#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中写道
and i wrote below in 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类型应该怎么做?
so what is should do to use mex type?
谢谢
推荐答案
我看到两个问题:
- 您不需要包含
<matrix.h>
,<mex.h>
中包含了<matrix.h>
.尝试:include "mex.h"
而不是<mex.h>
,然后删除include <matrix.h>
. -
mex -setup
找不到您的Microsoft Visual C ++ 2008编译器.
- You don't need to include
<matrix.h>
,<matrix.h>
is included inside<mex.h>
. Try:include "mex.h"
instead of<mex.h>
, and removeinclude <matrix.h>
. mex -setup
could not locate your Microsoft Visual C++ 2008 compiler.
选择菜单应如下所示:
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
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无法自动定位Visual2008.
Since Visual 2008 is newer than Matlab R2007b, Matlab can't automatically locate Visual 2008.
有一种方法可以手动添加.
请参阅此处: https://www.mathworks.com/matlabcentral/newsreader/view_thread/297616
There is a way to add it manually.
Refer here: https://www.mathworks.com/matlabcentral/newsreader/view_thread/297616
请考虑:由于我没有Matlab R2007b,我无法完全验证以下说明:
Please consider: I could not fully verify the following instructions because I don't have Matlab R2007b:
分步说明:
- 转到 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
- 执行
mex -setup
,并确认Visual Studio 2008在列表中.
- Go to https://www.mathworks.com/matlabcentral/fileexchange/18508-microsoft-visual-studio-2008-mex-and-mbuild-setup-files
- Download the zip file VS2008Matlab.zip (press the "Download zip" blue button on the top right side of the page).
- Extract the zip file.
- Copy folder content VS2008MATLABMexCompilerFilesX64 to:
C:\Program Files\MATALB\R2007b\bin\win64\mexopts
(assuming your version is 64 bit in default installation folder). - Copy folder content VS2008MATLABMBuildCompilerFilesX64 to:
C:\Program Files\MATALB\R2007b\bin\win64\msbuildopts
- Execute
mex -setup
, and verify Visual Studio 2008 is in the list.
这篇关于Microsoft Visual C ++ 2008和R2007b的Mex类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!