我们有一个用cpp编写的名为FaceTracker的项目,我们需要从另一个用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:\ 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 \ 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:\ Users \ hodhod \ Documents \ Jam3a \ PROJECT-2012 !! \ FindSymetryInFaces \ FaceTracker \ FaceTracker \ mexFile.cpp:2找不到包含文件`> Blockquote

我该如何解决这些错误?
预先感谢。

最佳答案

您将必须使用-I选项指定指向mex编译功能的所有必需包含路径,请参见help mex.这是一个示例:

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

10-04 14:18