我正在尝试编译运行OpenTLD项目所需的mex文件。
链接:https://github.com/zk00006/OpenTLD
使用:
OpenCV 2.4.9 64位, Matlab 2013b 64位
尝试运行compile.m时,出现以下错误。
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.
Error in compile (line 32)
eval(['mex lk.cpp -O' include lib]);
我知道它与使用其中一个OpenCV或Matlab的错误位版本(32/64)有关,但仍然无法解决问题。
答案 0 :(得分:0)
我能够解决这个问题,因为我使用的是最新版本的Matlab,2013b,这是一些语法问题。有趣的是,所有在线论坛都指出了我对32-64位问题的看法。无论如何,我在这里发布解决方案,以便将来它可以帮助某人。
这是我在compile.m中做的修改。第25-30行:
files = dir(fullfile(libpath, '*.lib'));
lib = [];
for i = 1:length(files),
lib = [lib ' ' libpath '\' files(i).name];
end
它之前没有正确读取变量lib中的.lib文件,因此链接错误。