Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when run compile.m #35

Open
ghost opened this issue Oct 13, 2012 · 22 comments
Open

Errors when run compile.m #35

ghost opened this issue Oct 13, 2012 · 22 comments

Comments

@ghost
Copy link

ghost commented Oct 13, 2012

Hi,

I am installing the TLD application based on the instructions shown on https://github.com/zk00006/OpenTLD/wiki/Installation

Using:

OpenCV 2.4.2

Matlab R2010b x 64bits

Win7 x 64

VS2010 Professional

Everything works fine until I executed this step "6) In Matlab, run compile.m"

"
PC
Creating library C:\Users\Ko\AppData\Local\Temp\mex_VUBK1k\templib.x and object C:\Users\Ko\AppData\Local\Temp\mex_VUBK1k\templib.exp

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 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 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 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 cvCalcOpticalFlowPyrLK referenced in function mexFunction

lk.obj : error LNK2019: unresolved external symbol cvAlloc referenced in function mexFunction

lk.mexw64 : fatal error LNK1120: 6 unresolved externals

C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'lk.mexw64' failed.

??? Error using ==> mex at 208
Unable to complete successfully.

Error in ==> compile at 32
eval(['mex lk.cpp -O' include lib]);

"

I have searched through many websites but to no avail. Hopefully, someone can enlighten me on this problem. All solutions are greatly appreciated

Cheers,
Ko

@Ska-K
Copy link

Ska-K commented Nov 20, 2012

Same issue here, but with Win7 32b, MATLAB 2009b and VS2008. Did you find any solution? I'm trying to guess what happens.

Edit:

OK, got it. Actually it's a silly error. As you can see in compile.m, you need to have OpenCV headers and libs in the proper directories:

include = ' -Ic:\OpenCV2.2\include\opencv\ -Ic:\OpenCV2.2\include\';
libpath = 'c:\OpenCV2.2\lib\';

Do it manually if it's necessary, it will work. :)

@davidhere40
Copy link

I had the same issue. You'll get the above errors if you are mixing 32 bit and 64 bit. Your openCV must have been compiled as 32bit.
I got it to compile by changing the libpath to:
libpath = 'C:\OpenCV-2.4.0\opencv\build\x64\vc10\lib';

This is because my matlab is 64bit, but I compiled openCV as 32bit. So, I found some precompiled libraries and used those.

@ghost
Copy link
Author

ghost commented Dec 20, 2012

Thanks a lot for the solution provided. I managed to resolve the problem.

@JLLL
Copy link

JLLL commented Feb 12, 2013

Hi, i got this error, compile of 'lk.cpp' failed.

Cannot open include file: 'opencv2/core/core_c.h'

I tried to put "opencv\build\include\opencv2\core in the include string but still unable to solve it. Any help?

@ygx2011
Copy link

ygx2011 commented Mar 27, 2013

opencv 2.4.3
win7 64bit
vs2010b
??? Invalid MEX-file 'C:\Users\yinggaoxuan\Desktop\TLD\mex\lk.mexw64':
C:\Users\yinggaoxuan\Desktop\TLD\mex\lk.mexw64 不是有效的 Win32 应用程序。

.

Error in ==> tldInit at 20
lk(0);

Error in ==> tldExample at 34
tld = tldInit(opt,[]);% train initial detector and initialize the 'tld' structure

Error in ==> run_TLD at 42
[bb,conf] = tldExample(opt);

I'll be very glad if someone can help me.

@ygx2011
Copy link

ygx2011 commented Mar 27, 2013

Any help?

@ygx2011
Copy link

ygx2011 commented Mar 27, 2013

opencv 2.4.3
win7 64bit
vs2010b
??? Invalid MEX-file 'C:\Users\yinggaoxuan\Desktop\TLD\mex\lk.mexw64':
C:\Users\yinggaoxuan\Desktop\TLD\mex\lk.mexw64 is not a valid Win32 application

.

Error in ==> tldInit at 20
lk(0);

Error in ==> tldExample at 34
tld = tldInit(opt,[]);% train initial detector and initialize the 'tld' structure

Error in ==> run_TLD at 42
[bb,conf] = tldExample(opt);

I'll be very glad if someone can help me.

@the13thson
Copy link

If I'm not mistaken - their software only runs on OpenCV 2.2 --- I may be wrong, but I'm also trying to get it work, and I read that last night.

@ygx2011
Copy link

ygx2011 commented Mar 27, 2013

I have a classmate,his computer is 32bit,and his opencv is 2.4.3,it can runs on his computer,now,I have the same error with kolz.

@niunuinui
Copy link

i think u need OpenCV dll in x64 when you compile compile.m in a WIN7 x64 PC.
So add OpenCV x64 dll instead of x86 dll to PATH, then "not a valid Win32 application" issue must be solved

@freakbird
Copy link

@kolz @davidhere40

I am also using OpenCV - 2.4.9 and Matlab 2013b both 64-bit.
and getting the same issue.
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'lk.mexw64' failed.

Any directions on how to resolve it?

@ygx2011
Copy link

ygx2011 commented Dec 17, 2014

i think the problem is the mix of c and matlab,you can run the C code on ubuntu,and i konw a way to run the matlab code on OS X,not windows.

@freakbird
Copy link

I was able to solve the issue, it was some syntax issue as I was using a recent version of Matlab. 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.

@simonsayshi
Copy link

@davidhere40 I believe I met the mixing issue too. however I failed to configure the 64bit when I use Cmake. I've searched a lot but none solved my problem. below is the error.
Plus, do I have to install vs2010 if I'm going to compile 64bit with the vs2010 win64 option? it seems MS doesn't provide vs2010 anymore

capture

@davidhere40
Copy link

davidhere40 commented Feb 20, 2018 via email

@simonsayshi
Copy link

simonsayshi commented Feb 20, 2018

@davidhere40 thanks for reply! here attached the rest error message
And I do have a MS account. the link you gave me is exactly what I searched for the older VS version but the vs2010 is not available to download. However there is Visual Studio 2010 VC++ Redistributable at the bottom and I installed it,but the issue remains:(
this problem is driving me crazy:(

can you still run this compile.m on your PC?

image

@davidhere40
Copy link

davidhere40 commented Feb 20, 2018 via email

@simonsayshi
Copy link

@davidhere40 now I successfully compiled the 64bit(yes I'm still dealing with it:( ) but when I run compile.m I met the issue:
https://github.com/zk00006/OpenTLD/issues/52

every time I feel close to the result, I ran into errors :(
any solution for this?

@davidhere40
Copy link

davidhere40 commented Feb 20, 2018 via email

@davidhere40
Copy link

davidhere40 commented Feb 20, 2018 via email

@simonsayshi
Copy link

@davidhere40 now I solved this problem..I just change matlab from 2017a to 2014b..........
now it can track the object I circled.
but I still have question, since it mark objects in each frame, is that possible to save the frames having bounding box on the objects as a single image?

@davidhere40
Copy link

davidhere40 commented Feb 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants