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

时间:2015-01-11 13:44:55

标签: matlab linker-errors mex lnk2019 lnk2001

我正在尝试从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.  

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:1)

您尝试编译的软件包包含三个cpp文件,但它们应编译为单个 mex文件。
因此,他们只在其中定义了一个mexFunction符号 尝试

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