使用 mex 时出错(第 206 行)无法成功完成

Error using mex (line 206) Unable to complete successfully

我正在尝试从 this link 编译 cpp 文件,但我收到以下错误:

>> mex OpticalFlow.cpp

LINK : error LNK2001: unresolved external symbol mexFunction   
C:\Users\pc\AppData\Local\Temp\mex_Fe1hah\templib.x :   
fatal error LNK1120: 1 unresolved externals    
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'OpticalFlow.mexw32' failed. 

>> mex GaussianPyramid.cpp

LINK : error LNK2001: unresolved external symbol mexFunction  
C:\Users\pc\AppData\Local\Temp\mex_IWT6TB\templib.x : fatal error LNK1120: 1 unresolved externals  
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'GaussianPyramid.mexw32' failed.   
Creating library C:\Users\pc\AppData\Local\Temp\mex_5guviT\templib.x and object  C:\Users\pc\AppData\Local\Temp\mex_5guviT\templib.exp  
Coarse2FineTwoFrames.obj : error LNK2019: unresolved external symbol "public: static void __cdecl OpticalFlow::Coarse2FineFlow(class Image<double> &,class Image<double> &,class Image<double> &,class Image<double> const &,class Image<double> const &,double,double,int,int,int,int)" (?Coarse2FineFlow@OpticalFlow@@SAXAAV?$Image@N@@00ABV2@1NNHHHH@Z) referenced in function _mexFunction  
Coarse2FineTwoFrames.mexw32 : fatal error LNK1120: 1 unresolved externals   
E:\MATLAB2\R2013A\BIN\MEX.PL: Error: Link of 'Coarse2FineTwoFrames.mexw32' failed.   
Error using mex (line 206)  
Unable to complete successfully.  

有人可以帮我吗?

您尝试编译的包包含三个 cpp 文件,但它们应该编译成一个单个 mex 文件。
结果他们只定义了一个 mexFunction 符号。
尝试

>> mex -O -largeArrayDims Coarse2FineTwoFrames.cpp GaussianPyramid.cpp OpticalFlow.cpp