奇怪的是,其他应用程序文件夹中的 haartraining 通过采用完全相同的方式工作得很好。我在想在定义必要文件的路径时有一个错误,但一切看起来都很好。
这是我的设置(假设 OpenCV 2.4.5 和 Visual Studio):
- 在环境变量中设置 DLL 路径:
- 设置
OPENCV245_DIR
为C:\opencv\opencv245\build\x86\vc10\bin
- 添加
%OPENCV245_DIR%
到PATH
- 设置
- 配置包含目录:
C:\opencv\opencv245\build\include
C:\opencv\opencv245\build\include\opencv
C:\opencv\opencv245\apps\traincascade
- 配置库目录:
C:\opencv\opencv245\build\x86\vc10\lib
- 配置
.lib
依赖:opencv_core245d.lib
opencv_ml245d.lib
opencv_imgproc245d.lib
opencv_objdetect245d.lib
opencv_highgui245d.lib
opencv_calib3d245d.lib
opencv_video245d.lib
opencv_features2d245d.lib
opencv_flann245d.lib
opencv_legacy245d.lib
opencv_haartraining_engined.lib
opencv_contrib245d.lib
opencv_gpu245d.lib
opencv_nonfree245d.lib
opencv_photo245d.lib
opencv_stitching245d.lib
opencv_ts245d.lib
opencv_videostab245d.lib
我为调试和发布模式制作了一个属性表。Debug|Win32
我将工作表作为“属性表”窗格中(或)文件夹下的第一项放在顶部Release|Win32
,因为我读到工作表的顺序决定了它们的优先级。此外,Release
属性表省略了文件名d
末尾的。.lib
如果我尝试编译代码,我会得到以下输出:
1>------ Build started: Project: traincascade245, Configuration: Debug Win32 ------
1>Build started 4/12/2013 3:11:03 PM.
1>InitializeBuildStatus:
1> Touching "Debug\traincascade245.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>Link:
1>
1> Searching libraries
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_core245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ml245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_imgproc245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_objdetect245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_highgui245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_calib3d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_video245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_features2d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_flann245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_legacy245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_haartraining_engined.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_contrib245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_gpu245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_nonfree245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_photo245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_stitching245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ts245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_videostab245d.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRTD.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_core245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ml245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_imgproc245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_objdetect245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_highgui245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_calib3d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_video245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_features2d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_flann245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_legacy245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_haartraining_engined.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_contrib245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_gpu245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_nonfree245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_photo245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_stitching245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ts245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_videostab245d.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRTD.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_core245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ml245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_imgproc245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_objdetect245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_highgui245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_calib3d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_video245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_features2d245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_flann245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_legacy245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_haartraining_engined.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_contrib245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_gpu245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_nonfree245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_photo245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_stitching245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_ts245d.lib:
1> Searching C:\opencv\opencv245\build\x86\vc10\lib\opencv_videostab245d.lib:
1>
1> Finished searching libraries
1>traincascade.obj : error LNK2019: unresolved external symbol "public: bool __thiscall CvCascadeClassifier::train(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,int,int,class CvCascadeParams const &,class CvFeatureParams const &,struct CvCascadeBoostParams const &,bool)" (? train@CvCascadeClassifier@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@00HHHHHABVCvCascadeParams@@ABVCvFeatureParams@@ABUCvCascadeBoostParams @@_N@Z) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvCascadeBoostParams::scanAttr(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (? scanAttr@CvCascadeBoostParams@@UAE_NV?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@0@Z) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvCascadeParams::scanAttr(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?scanAttr@CvCascadeParams@@UAE_NV? $basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall CvCascadeBoostParams::printDefaults(void)const " (? printDefaults@CvCascadeBoostParams@@UBEXXZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall CvCascadeParams::printDefaults(void)const " (? printDefaults@CvCascadeParams@@UBEXXZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvHOGFeatureParams::CvHOGFeatureParams(void)" (??0CvHOGFeatureParams@@QAE@XZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvLBPFeatureParams::CvLBPFeatureParams(void)" (??0CvLBPFeatureParams@@QAE@XZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvHaarFeatureParams::CvHaarFeatureParams(void)" (??0CvHaarFeatureParams@@QAE@XZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvCascadeBoostParams::CvCascadeBoostParams(void)" (??0CvCascadeBoostParams@@QAE@XZ) referenced in function _main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvCascadeParams::CvCascadeParams(void)" (??0CvCascadeParams@@QAE@XZ) referenced in function _main
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CvCascadeBoostParams::printAttrs(void)const " (?printAttrs@CvCascadeBoostParams@@UBEXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CvParams::printDefaults(void)const " (?printDefaults@CvParams@@UBEXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CvParams::printAttrs(void)const " (?printAttrs@CvParams@@UBEXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CvParams::scanAttr(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?scanAttr@CvParams@@UAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvCascadeImageReader::PosReader::~PosReader(void)" (??1PosReader@CvCascadeImageReader@@UAE@XZ) referenced in function __unwindfunclet$??0CvCascadeImageReader@@QAE@XZ$0
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvCascadeImageReader::NegReader::NegReader(void)" (??0NegReader@CvCascadeImageReader@@QAE@XZ) referenced in function "public: __thiscall CvCascadeImageReader::CvCascadeImageReader(void)" (??0CvCascadeImageReader@@QAE@XZ)
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __thiscall CvCascadeImageReader::PosReader::PosReader(void)" (??0PosReader@CvCascadeImageReader@@QAE@XZ) referenced in function "public: __thiscall CvCascadeImageReader::CvCascadeImageReader(void)" (??0CvCascadeImageReader@@QAE@XZ)
1>C:\Users\knobukaw\Documents\Visual Studio 2010\Projects\traincascade245\Debug\traincascade245.exe : fatal error LNK1120: 17 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.52
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========