PDA

View Full Version : Linker errors with simple QDirIterator program (which libs to invlude?)



prophetjohn
10th September 2011, 23:44
Hi, folks, new to Qt. I'm working on updating an application that performs a special kind of comparison on images and my job is to integrate functionality that automates this over a whole directory. It looks like Qt's QDirIterator library is more robust and much better documented than Boost's filesystem (which I already have working), so I want to get this working in Qt, but I'm getting linker errors when compiling this in VC++ '08. This is, of course, just a trivial application to print the names of the files so I can get a feel for the library. Any insight into which libs I should include?



void show_files(const string &path)
{
QDir directory;
QString str = QString::fromStdString(path);
directory.setPath(str);
string fileName = "",
direc = directory.path().toStdString(),
ext;

int num_files_seen = 0;

if ( directory.exists() )
{
QDirIterator i(directory);

while( i.hasNext() )
{
if( i.fileInfo().isDir() )
direc = i.fileInfo().path().toStdString();
else
{
fileName = i.fileInfo().fileName().toStdString();
ext = i.fileInfo().suffix().toStdString();
cout << fileName << " is in " << direc
<< " and has the file extension " << ext << endl;
num_files_seen++;
}
}
}
cout << num_files_seen << " seen.\n";
}


1>------ Build started: Project: iter, Configuration: Debug Win32 ------
1>Linking...
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QDir::~QDir(void)" (__imp_??1QDir@@QAE@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QDirIterator::~QDirIterator(void)" (__imp_??1QDirIterator@@UAE@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QFileInfo::suffix(void)const " (__imp_?suffix@QFileInfo@@QBE?AVQString@@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QFileInfo::fileName(void)const " (__imp_?fileName@QFileInfo@@QBE?AVQString@@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QFileInfo::path(void)const " (__imp_?path@QFileInfo@@QBE?AVQString@@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QFileInfo::~QFileInfo(void)" (__imp_??1QFileInfo@@QAE@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QFileInfo::isDir(void)const " (__imp_?isDir@QFileInfo@@QBE_NXZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QFileInfo __thiscall QDirIterator::fileInfo(void)const " (__imp_?fileInfo@QDirIterator@@QBE?AVQFileInfo@@XZ ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QDirIterator::hasNext(void)const " (__imp_?hasNext@QDirIterator@@QBE_NXZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QDirIterator::QDirIterator(class QDir const &,class QFlags<enum QDirIterator::IteratorFlag>)" (__imp_??0QDirIterator@@QAE@ABVQDir@@V?$QFlags@W4I teratorFlag@QDirIterator@@@@@Z) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QDir::exists(void)const " (__imp_?exists@QDir@@QBE_NXZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall QString::toStdString(void)const " (__imp_?toStdString@QString@@QBE?AV?$basic_string@ DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QDir::path(void)const " (__imp_?path@QDir@@QBE?AVQString@@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QDir::setPath(class QString const &)" (__imp_?setPath@QDir@@QAEXABVQString@@@Z) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QString::fromStdString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?fromStdString@QString@@SA?AV1@ABV?$basic_s tring@DU?$char_traits@D@std@@V?$allocator@D@2@@std @@@Z) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)" (__imp_??1QString@@QAE@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QDir::QDir(class QString const &)" (__imp_??0QDir@@QAE@ABVQString@@@Z) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>iter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::QString(void)" (__imp_??0QString@@QAE@XZ) referenced in function "void __cdecl show_files(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?show_files@@YAXABV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@@Z)
1>C:\Users\Josh\Documents\Visual Studio 2008\Projects\/bin/iterd.exe : fatal error LNK1120: 18 unresolved externals
1>Build log was saved at "file://C:\Users\Josh\Documents\Visual Studio 2008\Projects\Build\iter\Debug\BuildLog.htm"
1>iter - 19 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Thanks!

ChrisW67
12th September 2011, 08:18
QDir and friends are part of the same library as QString (also failing): QtCore

Are you linking against Qt libraries built with VC 2008?