从Matlab调用Cpp项目

时间:2012-02-24 21:18:09

标签: c++ c matlab mex

我们有一个名为FaceTracker的项目是用cpp编写的,我们需要从另一个用matlab编写的项目中调用它。 我们成功地使用“mex”和“mexfunction”(用c编写)从matlab调用单个函数。 当我们尝试调用整个项目时,我们添加了以下源文件:

#include "mex.h"
#include "FaceTracker.h"

void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
... // code
/* Call the "main" C++ subroutine. */
FaceTracker( buflen, input_buf);
}

并尝试通过输入以下内容在matlab中编译它:“mex mexFile.cpp” 但是我们遇到了以下错误:

`lcc预处理器错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ stdafx.h:13 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:4 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件

lcc预处理程序错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ stdafx.h:14 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012! !\ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:4 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件“ cv.h“

lcc预处理程序错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ stdafx.h:15 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012! !\ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:4 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件“ highgui.h“

lcc预处理程序错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ stdafx.h:16 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012! !\ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:4 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件“ cxcore.h“

lcc预处理程序错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ IO.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012! !\ FindSymetryInFaces \ FaceTracker \ FaceTracker \ PDM.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ CLM.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ Tracker.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:5 C:\用户\ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件“cv.h”

lcc预处理程序错误:C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ IO.h:44 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012! !\ FindSymetryInFaces \ FaceTracker \ FaceTracker \ PDM.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ CLM.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ Tracker.h:42 C:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ FaceTracker.h:5 C:\用户\ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件`>块引用

如何解决这些错误? 提前谢谢。

1 个答案:

答案 0 :(得分:1)

您将必须使用-I选项指定mex编译函数的所有必需包含路径,请参阅help mex.以下是一个示例:

 mex -v -g -IC:\Users\hodhod\Documents\Jam3a\PROJECT-2012!!\FindSymetryInFaces\FaceTracker\FaceTracker\SomeMissingIncludes mexFile.cpp