Results 1 to 2 of 2

Thread: Linker errors with simple QDirIterator program (which libs to invlude?)

  1. #1
    Join Date
    Sep 2011
    Posts
    11
    Qt products
    Qt3
    Platforms
    Windows

    Default Linker errors with simple QDirIterator program (which libs to invlude?)

    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?

    Qt Code:
    1. void show_files(const string &path)
    2. {
    3. QDir directory;
    4. QString str = QString::fromStdString(path);
    5. directory.setPath(str);
    6. string fileName = "",
    7. direc = directory.path().toStdString(),
    8. ext;
    9.  
    10. int num_files_seen = 0;
    11.  
    12. if ( directory.exists() )
    13. {
    14. QDirIterator i(directory);
    15.  
    16. while( i.hasNext() )
    17. {
    18. if( i.fileInfo().isDir() )
    19. direc = i.fileInfo().path().toStdString();
    20. else
    21. {
    22. fileName = i.fileInfo().fileName().toStdString();
    23. ext = i.fileInfo().suffix().toStdString();
    24. cout << fileName << " is in " << direc
    25. << " and has the file extension " << ext << endl;
    26. num_files_seen++;
    27. }
    28. }
    29. }
    30. cout << num_files_seen << " seen.\n";
    31. }
    32.  
    33.  
    34. 1>------ Build started: Project: iter, Configuration: Debug Win32 ------
    35. 1>Linking...
    36. 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)
    37. 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)
    38. 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)
    39. 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)
    40. 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)
    41. 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)
    42. 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)
    43. 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)
    44. 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)
    45. 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@W4IteratorFlag@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)
    46. 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)
    47. 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)
    48. 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)
    49. 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)
    50. 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_string@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)
    51. 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)
    52. 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)
    53. 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)
    54. 1>C:\Users\Josh\Documents\Visual Studio 2008\Projects\/bin/iterd.exe : fatal error LNK1120: 18 unresolved externals
    55. 1>Build log was saved at "file://C:\Users\Josh\Documents\Visual Studio 2008\Projects\Build\iter\Debug\BuildLog.htm"
    56. 1>iter - 19 error(s), 0 warning(s)
    57. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    To copy to clipboard, switch view to plain text mode 

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Linker errors with simple QDirIterator program (which libs to invlude?)

    QDir and friends are part of the same library as QString (also failing): QtCore

    Are you linking against Qt libraries built with VC 2008?

Similar Threads

  1. Linker errors with Q_OBJECT
    By dustin034 in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2010, 19:14
  2. Additional libs for linker
    By megabyte-ceercop in forum Qt Tools
    Replies: 3
    Last Post: 26th March 2009, 06:16
  3. please help with linker errors
    By jimboqt in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 09:49
  4. Linker errors!!
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 25th April 2006, 08:14
  5. Linker Errors
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 7th March 2006, 18:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.