编译OpenTLD compile.m时出错(Error while compiling OpenTLD compile.m)

我正在尝试编译运行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)进行构建有关,但仍然无法解决问题。

I am trying to compile the mex files needed to run OpenTLD project.

Link : https://github.com/zk00006/OpenTLD

Using:

OpenCV 2.4.9 64-bit, Matlab 2013b 64-bit

When trying to run compile.m, I get the following error.

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]);

I know it has something to do with using wrong bit version(32/64) of one of the OpenCV or Matlab to build, but still can't resolve the issue.

最满意答案

我能够解决这个问题,因为我使用的是最新版本的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文件,因此链接错误。

I was able to solve the issue, it was some syntax issue as I was using a recent version of Matlab, 2013b. It's funny how all the forums online pointed me towards the 32-64 bit problem. Anyway I am posting the solution here so that in future it might help someone.

This was the modification I made in compile.m. Lines 25-30:

files = dir(fullfile(libpath, '*.lib')); lib = []; for i = 1:length(files), lib = [lib ' ' libpath '\' files(i).name]; end

It was not reading the .lib files in the variable lib properly before and thus error in linking.

编译OpenTLD compile.m时出错(Error while compiling OpenTLD compile.m)

我正在尝试编译运行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)进行构建有关,但仍然无法解决问题。

I am trying to compile the mex files needed to run OpenTLD project.

Link : https://github.com/zk00006/OpenTLD

Using:

OpenCV 2.4.9 64-bit, Matlab 2013b 64-bit

When trying to run compile.m, I get the following error.

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]);

I know it has something to do with using wrong bit version(32/64) of one of the OpenCV or Matlab to build, but still can't resolve the issue.

最满意答案

我能够解决这个问题,因为我使用的是最新版本的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文件,因此链接错误。

I was able to solve the issue, it was some syntax issue as I was using a recent version of Matlab, 2013b. It's funny how all the forums online pointed me towards the 32-64 bit problem. Anyway I am posting the solution here so that in future it might help someone.

This was the modification I made in compile.m. Lines 25-30:

files = dir(fullfile(libpath, '*.lib')); lib = []; for i = 1:length(files), lib = [lib ' ' libpath '\' files(i).name]; end

It was not reading the .lib files in the variable lib properly before and thus error in linking.