Mex type for Microsoft Visual C++ 2008 and R2007b

守給你的承諾、 提交于 2020-01-24 12:20:07

问题


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");
}

and get this error

'matrix.h': No such file or directory

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: 

so what is should do to use mex type?

thanks


回答1:


I see two problems:

  1. You don't need to include <matrix.h>, <matrix.h> is included inside <mex.h>. Try: include "mex.h" instead of <mex.h>, and remove include <matrix.h>.
  2. mex -setup could not locate your Microsoft Visual C++ 2008 compiler.

The selection menu should look as follows:

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

Since Visual 2008 is newer than Matlab R2007b, Matlab can't automatically locate Visual 2008.

There is a way to add it manually.
Refer here: https://www.mathworks.com/matlabcentral/newsreader/view_thread/297616

Please consider: I could not fully verify the following instructions because I don't have Matlab R2007b:

Step by step instructions:

  1. Go to https://www.mathworks.com/matlabcentral/fileexchange/18508-microsoft-visual-studio-2008-mex-and-mbuild-setup-files
  2. Download the zip file VS2008Matlab.zip (press the "Download zip" blue button on the top right side of the page).
  3. Extract the zip file.
  4. Copy folder content VS2008MATLABMexCompilerFilesX64 to: C:\Program Files\MATALB\R2007b\bin\win64\mexopts (assuming your version is 64 bit in default installation folder).
  5. Copy folder content VS2008MATLABMBuildCompilerFilesX64 to: C:\Program Files\MATALB\R2007b\bin\win64\msbuildopts
  6. Execute mex -setup, and verify Visual Studio 2008 is in the list.


来源:https://stackoverflow.com/questions/38583411/mex-type-for-microsoft-visual-c-2008-and-r2007b

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!