c++ - Mergevec.obj : 10 unresolved linking errors (OpenCV samples collection for haartraining)

标签 c++ opencv compiler-errors linker haar-classifier

使用 this tutorial ,我正在尝试合并使用 opencv_createsamples 创建的不同 vector ,以便我可以进行一些 haartraining。

我正在使用 VS 2010 命令行界面编译 mergevec.cpp:

cl /EHsc mergevec.cpp

但我在此处收到 10 个 Unresolved external 错误:

/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

我该如何解决这些问题?我需要获取一些 .dll 吗? 我一直在努力让 mergevec 在不同的机器上工作 2 天!这是旧的问题吗?

顺便说一下,我将代码中的所有引用从 "cv.h" 更改为 "opencv.h",因为这是当前头文件的名称。

我正在尝试在具有以下结构的文件夹中编译 mergevec.cpp:

  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

文件夹opencv2有目录:core, highgui, flann, contrib etc etc.

编辑

根据您的意见,我更改了命令以包含库:

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

但它仍然显示相同的 10 个 Unresolved external 问题。无奈之下,我什至尝试包含每个库文件,但没有区别。

最佳答案

Visual Studio 好像没有找到 OpenCV 库,好像是 pkg-config 缺失的问题。检查这个,因为我不确定它在 Windows 上是如何工作的。您是否在项目属性中链接了 OpenCV 库?

否则,如果它仍然不能在 VS 上运行,我建议您在 Linux 下编译它(WM 或不是)。检查这个post了解更多信息。

关于c++ - Mergevec.obj : 10 unresolved linking errors (OpenCV samples collection for haartraining),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22916032/

相关文章:

c++ - 在 C++ 中使用构建器模式时,setter 返回对构建器对象的引用是否可取?

c++ - 重写 2 个重载继承方法之一 C++

c++ - 异步的令人费解的行为

opencv - Raspberry Pi 到 Arduino 通信

sql - 试图在 VBA 中解决 Object required 错误

c++ - 在 OpenCV 中找不到 FREAK 检测器

image - 如何使用 OpenCV 找到图像上每个轮廓的高度和宽度

eclipse - 在 openCv 中使用 calcCovarMatrix 时出错

Java,如何在屏幕上绘制矩形变量

compiler-errors - Lisp 非法函数调用,