Hello,
Since this is my first post, I will try to make it as clear as possible so that people could try to find the reason of this error together with me.
Brief: I am running openCV 2.4.2 on Windows 7 x64 and with Visual Studio 2010 C++ compiler
As followed by multiple guides online I made sure the following configurations were made
1) Be sure that Visual Studio knows that the win32 console application is for x64 bit system
2) At the C/C++ general settings of the project I got the following additional include directories
- D:\OpenCV2.4\build\include
- D:\OpenCV2.4\build\include\opencv
- D:\OpenCV2.4\build\include\opencv2
3) At the linker settings I added at general settings the following additional library directory
- D:\OpenCV2.4\build\x64\vc10\lib\
4) At the linker settings I added at the input settings the following additional dependencies
- opencv_core240d.lib
- opencv_imgproc240d.lib
- opencv_highgui240d.lib
- opencv_objdetect240d.lib
- opencv_calib3d240d.lib
- opencv_video240d.lib
- opencv_features2d240d.lib
- opencv_flann240d.lib
- opencv_legacy240d.lib
5)Included inside the project is all the files that can be found for the traincascade application under the folder:
- D:\OpenCV2.4\apps\traincascade\
This all should be enough to compile the traincascade.cpp file, in order to be able to train a classifier myself.
But I keep getting the following linking errors:
1>------ Build started: Project: traincascade, Configuration: Debug x64 ------
1>Build started 19/09/2012 16:02:53.
1>InitializeBuildStatus:
1> Touching "x64\Debug\traincascade.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>traincascade.obj : error LNK2019: unresolved external symbol "public: bool __cdecl 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,classCvCascadeParams const &,class CvFeatureParams const &,struct CvCascadeBoostParams const &,bool)" (?train@CvCascadeClassifier@QEAA_NV?$basic_string@DU?$char_traits@D@std@V?$allocator@D@2@std@00HHHHHAEBVCvCascadeParams@AEBVCvFeatureParams@AEBUCvCascadeBoostParams@_N@Z) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual bool __cdecl 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@UEAA_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 __cdecl 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@UEAA_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 __cdecl CvCascadeBoostParams::printDefaults(void)const " (?printDefaults@CvCascadeBoostParams@UEBAXXZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl CvCascadeParams::printDefaults(void)const " (?printDefaults@CvCascadeParams@UEBAXXZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvHOGFeatureParams::CvHOGFeatureParams(void)" (??0CvHOGFeatureParams@QEAA@XZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvLBPFeatureParams::CvLBPFeatureParams(void)" (0CvLBPFeatureParams@QEAA@XZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvHaarFeatureParams::CvHaarFeatureParams(void)" (??0CvHaarFeatureParams@QEAA@XZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvCascadeBoostParams::CvCascadeBoostParams(void)" (??0CvCascadeBoostParams@QEAA@XZ) referenced in function main
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvCascadeParams::CvCascadeParams(void)" (??0CvCascadeParams@QEAA@XZ) referenced in function main
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl CvCascadeBoostParams::printAttrs(void)const " (?printAttrs@CvCascadeBoostParams@UEBAXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl CvParams::printDefaults(void)const " (?printDefaults@CvParams@UEBAXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl CvParams::printAttrs(void)const " (?printAttrs@CvParams@UEBAXXZ)
1>traincascade.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl 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@UEAA_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 __cdecl CvCascadeImageReader::PosReader::~PosReader(void)" (??1PosReader@CvCascadeImageReader@UEAA@XZ) referenced in function "int `public: __cdecl CvCascadeImageReader::CvCascadeImageReader(void)'::`1'::dtor$0" (?dtor$0@?0?0CvCascadeImageReader@QEAA@XZ@4HA)
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvCascadeImageReader::NegReader::NegReader(void)" (??0NegReader@CvCascadeImageReader@QEAA@XZ) referenced in function "public: __cdecl CvCascadeImageReader::CvCascadeImageReader(void)" (??0CvCascadeImageReader@QEAA@XZ)
1>traincascade.obj : error LNK2019: unresolved external symbol "public: __cdecl CvCascadeImageReader::PosReader::PosReader(void)" (??0PosReader@CvCascadeImageReader@QEAA@XZ) referenced in function "public: __cdecl CvCascadeImageReader::CvCascadeImageReader(void)" (??0CvCascadeImageReader@@QEAA@XZ)
1>D:\ProjectTest\ClassifierTraining\x64\Debug\traincascade.exe : fatal error LNK1120: 17 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.51 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I discussed this issue with my current research group and none seems to find the answer to the problem, since we are all agreed that the correct libraries are added to the project, containing the functions the linker has problems with.
Anyone has any clue on how this could be solved? Or is this a bug for this specific configuration of windows/openCV/visual studio?
Kind regards,
Steven
ps. Code that i am using can be seen here
#include "cv.h"
#include "cascadeclassifier.h"
using namespace std;
int main( int argc, char* argv[] )
{
CvCascadeClassifier classifier;
String cascadeDirName, vecName, bgName;
int numPos = 2000;
int numNeg = 1000;
int numStages = 20;
int precalcValBufSize = 256,
precalcIdxBufSize = 256;
bool baseFormatSave = false;
CvCascadeParams cascadeParams;
CvCascadeBoostParams stageParams;
Ptr<CvFeatureParams> featureParams[] = { Ptr<CvFeatureParams>(new CvHaarFeatureParams),
Ptr<CvFeatureParams>(new CvLBPFeatureParams),
Ptr<CvFeatureParams>(new CvHOGFeatureParams)
};
int fc = sizeof(featureParams)/sizeof(featureParams[0]);
if( argc == 1 )
{
cout << "Usage: " << argv[0] << endl;
cout << " -data <cascade_dir_name>" << endl;
cout << " -vec <vec_file_name>" << endl;
cout << " -bg <background_file_name>" << endl;
cout << " [-numPos <number_of_positive_samples = " << numPos << ">]" << endl;
cout << " [-numNeg <number_of_negative_samples = " << numNeg << ">]" << endl;
cout << " [-numStages <number_of_stages = " << numStages << ">]" << endl;
cout << " [-precalcValBufSize <precalculated_vals_buffer_size_in_Mb = " << precalcValBufSize << ">]" << endl;
cout << " [-precalcIdxBufSize <precalculated_idxs_buffer_size_in_Mb = " << precalcIdxBufSize << ">]" << endl;
cout << " [-baseFormatSave]" << endl;
cascadeParams.printDefaults();
stageParams.printDefaults();
for( int fi = 0; fi < fc; fi++ )
featureParams[fi]->printDefaults();
return 0;
}
for( int i = 1; i < argc; i++ )
{
bool set = false;
if( !strcmp( argv[i], "-data" ) )
{
cascadeDirName = argv[++i];
}
else if( !strcmp( argv[i], "-vec" ) )
{
vecName = argv[++i];
}
else if( !strcmp( argv[i], "-bg" ) )
{
bgName = argv[++i];
}
else if( !strcmp( argv[i], "-numPos" ) )
{
numPos = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-numNeg" ) )
{
numNeg = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-numStages" ) )
{
numStages = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-precalcValBufSize" ) )
{
precalcValBufSize = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-precalcIdxBufSize" ) )
{
precalcIdxBufSize = atoi( argv[++i] );
}
else if( !strcmp( argv[i], "-baseFormatSave" ) )
{
baseFormatSave = true;
}
else if ( cascadeParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
else if ( stageParams.scanAttr( argv[i], argv[i+1] ) ) { i++; }
else if ( !set )
{
for( int fi = 0; fi < fc; fi++ )
{
set = featureParams[fi]->scanAttr(argv[i], argv[i+1]);
if ( !set )
{
i++;
break;
}
}
}
}
classifier.train( cascadeDirName,
vecName,
bgName,
numPos, numNeg,
precalcValBufSize, precalcIdxBufSize,
numStages,
cascadeParams,
*featureParams[cascadeParams.featureType],
stageParams,
baseFormatSave );
return 0;
}