1

Using this tutorial, I'm trying to merge the different vectors that were created using opencv_createsamples so that I can do some haartraining.

I'm compiling mergevec.cpp using the VS 2010 command line interface:

cl /EHsc mergevec.cpp

But I get 10 unresolved externals errors, here:

/out:mergevec.exe
mergevec.obj

mergevec.obj : error LNK2019: unresolved external symbol _cvFree_ referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvReleaseMat referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int*,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol "void __cdecl icvWriteVecSample(struct _iobuf *,void *)" (?icvWriteVecSample@@YAXPAU_iobuf@@PAX@Z) referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol "int __cdecl icvGetHaar
TraininDataFromVecCallback(struct CvMat *,void *)" (?icvGetHaarTraininDataFromVecCallback@@YAHPAUCvMat@@PAX@Z) referenced in function "void __cdecl icvAppendVec (struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvV
ecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvCreateMat referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvAlloc referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *, int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function "void __cdecl icvAppendVec(struct CvVecFile &,struct CvVecFile &,int *,int,int)" (?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)

mergevec.obj : error LNK2019: unresolved external symbol "void __cdecl icvWriteV
ecHeader(struct _iobuf *,int,int,int)" (?icvWriteVecHeader@@YAXPAU_iobuf@@HHH@Z)  referenced in function "void __cdecl icvMergeVecs(char *,char const *,int,int,int)" (?icvMergeVecs@@YAXPADPBDHHH@Z)

mergevec.exe : fatal error LNK1120: 10 unresolved externals

How can I fix these problems? Do I need to get some .dlls? I've been struggling with getting mergevec to work, on different machines, for 2 days! Is the problem that this is old?

By the way, I changed all references in the code from "cv.h" to "opencv.h", since that's the current header file's name.

I'm trying to compile mergevec.cpp in a folder with the following structure:

  opencv/
  opencv2/

CMakeLists.txt
createsamples.cpp
cvboost.cpp
cvclassifier.h
cvcommon.cpp
cvhaarclassifier.cpp
cvhaartraining.cpp
cvhaartraining.h
cvsamples.cpp
cxcore.h
cxmisc.h
haartraining.cpp
mergevec.cpp
opencv.hpp
performance.cpp
_cvcommon.h
_cvhaartraining.h

The folder opencv2 has directories: core, highgui, flann, contrib etc etc.

Edit

Based on your comments, I've changed the command to include the libraries:

cl /EHsc mergevec.cpp 
C:\opencv\build\x64\vc10\lib\opencv_core247d.lib 
C:\opencv\build\x64\vc10\lib\opencv_highgui247d.lib 
C:\opencv\build\x64\vc10\lib\opencv_flann247d.lib 
C:\opencv\build\x64\vc10\lib\opencv_imgproc247d.lib

But it's still showing the same 10 unresolved externals. In desperation I even tried including every single library file, but no difference.

user961627
  • 12,379
  • 42
  • 136
  • 210
  • 2
    cl /EHsc mergevec.cpp some_opencv.lib – berak Apr 07 '14 at 15:10
  • Yeah, you need to add the names of OpenCV .lib files, libopencv_core, libopencv_highgui, libopencv_imgproc and maybe a few others. – karlphillip Apr 07 '14 at 15:19
  • I've done as you said, and edited my question to include my new command. There's no difference. Are you sure these linking errors are related to the *.lib files? – user961627 Apr 07 '14 at 16:09
  • Looking at the errors, a lot of them have this in common: **(?icvAppendVec@@YAXAAUCvVecFile@@0PAHHH@Z)**. Does that help in any way? – user961627 Apr 07 '14 at 16:19
  • 1
    The errors are saying that the linker can't find symbols for core OpenCV functions, so, yes, it's a problem related to the lib files that are trying to be linked into your program. Try running dumpbin on your libraries and seeing if you can find the symbols manually. If not something might be wrong with the libraries you installed. Also, make sure you're compiling your code using a 64 bit compiler/linker. From the path names you reference looks like your OpenCV build is 64 bit, the linker won't find the symbols if you're referencing 64 bit libraries in a 32 bit build. – photoionized Apr 07 '14 at 19:34
  • Yes I installed 64-bit opencv, because my windows is 64-bit. How can I use DUMPBIN to help me with the linker issue? I did 'DUMPBIN /symbols mergevec.obj > symbols.txt', and it showed me that in fact the same symbols mentioned in the errors were "UNDEF" (undefined I guess). Then I ran 'DUMPBIN /symbols *.lib', but that didn't bring up a single one of the undefined symbols that this linker file is complaining of. I'm guessing that means that those symbols don't exist in any .lib file? Then what else can I try? Find .lib files from an older opencv version? Or get dll files instead? – user961627 Apr 07 '14 at 20:54

1 Answers1

0

Visual Studio doesn't seems to find the OpenCV library, it seems like a pkg-config missing problem. Check for this as i am not sure how it works on windows. Do you have linked the OpenCV library in your project properties?

Otherwise if it still doesn't work on VS i suggest you to compile it under Linux (WM or not). Check this post for further informations.

Community
  • 1
  • 1
Lucas
  • 106
  • 1
  • 5