关键错误:
Creating library C:\Users\Saurabh\AppData\Local\Temp\mex_sT0LV8\templib.x and object C:\Users\Saurabh\AppData\Local\Temp\mex_sT0LV8\templib.exp
lk.obj : error LNK2019: unresolved external symbol cvAlloc referenced in function mexFunction
lk.obj : error LNK2019: unresolved external symbol cvCreateImage referenced in function "void __cdecl normCrossCorrelation(struct _IplImage *,struct _IplImage *,struct CvPoint2D32f *,struct CvPoint2D32f *,int,char *,float *,int,int)" (?normCrossCorrelation@@YAXPEAU_IplImage@@0PEAUCvPoint2D32f@@1HPEADPEAMHH@Z)
lk.obj : error LNK2019: unresolved external symbol cvReleaseImage referenced in function "void __cdecl normCrossCorrelation(struct _IplImage *,struct _IplImage *,struct CvPoint2D32f *,struct CvPoint2D32f *,int,char *,float *,int,int)" (?normCrossCorrelation@@YAXPEAU_IplImage@@0PEAUCvPoint2D32f@@1HPEADPEAMHH@Z)
lk.obj : error LNK2019: unresolved external symbol cvGetRectSubPix referenced in function "void __cdecl normCrossCorrelation(struct _IplImage *,struct _IplImage *,struct CvPoint2D32f *,struct CvPoint2D32f *,int,char *,float *,int,int)" (?normCrossCorrelation@@YAXPEAU_IplImage@@0PEAUCvPoint2D32f@@1HPEADPEAMHH@Z)
lk.obj : error LNK2019: unresolved external symbol cvMatchTemplate referenced in function "void __cdecl normCrossCorrelation(struct _IplImage *,struct _IplImage *,struct CvPoint2D32f *,struct CvPoint2D32f *,int,char *,float *,int,int)" (?normCrossCorrelation@@YAXPEAU_IplImage@@0PEAUCvPoint2D32f@@1HPEADPEAMHH@Z)
lk.obj : error LNK2019: unresolved external symbol cvCalcOpticalFlowPyrLK referenced in function mexFunction
lk.mexw64 : fatal error LNK1120: 6 unresolved externals
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'lk.mexw64' failed.
Unable to complete successfully.
解决办法:
修改文件compile.m. Lines 25-30:为
files = dir(fullfile(libpath, '*.lib'));
lib = [];
for i = 1:length(files),
lib = [lib ' ' libpath '\' files(i).name];
end
本文详细介绍了在使用Matlab进行开发时遇到的LNK2019未解析外部符号错误,并提供了具体的解决步骤。通过修改编译脚本中的库文件路径,可以有效解决这一问题。

被折叠的 条评论
为什么被折叠?



