views:

264

answers:

1
+1  Q: 

Qt Linker Errors

Hi All,

I've been trying to get Qt working (QCreator, QIde and now VS2008).

I have sorted out a ton of issues already, but I am now faced with the following build errors, and frankly I'm out of ideas.

Error   1   error LNK2019: unresolved external symbol "public: void __thiscall FileVisitor::processFileList(class QStringList)" (?processFileList@FileVisitor@@QAEXVQStringList@@@Z) referenced in function _main   codevisitor-test.obj    Question1
Error   2   error LNK2019: unresolved external symbol "public: void __thiscall FileVisitor::processEntry(class QString)" (?processEntry@FileVisitor@@QAEXVQString@@@Z) referenced in function _main codevisitor-test.obj    Question1
Error   3   error LNK2019: unresolved external symbol "public: class QString __thiscall ArgumentList::getSwitchArg(class QString,class QString)" (?getSwitchArg@ArgumentList@@QAE?AVQString@@V2@0@Z) referenced in function _main   codevisitor-test.obj    Question1
Error   4   error LNK2019: unresolved external symbol "public: bool __thiscall ArgumentList::getSwitch(class QString)" (?getSwitch@ArgumentList@@QAE_NVQString@@@Z) referenced in function _main    codevisitor-test.obj    Question1
Error   5   error LNK2019: unresolved external symbol "public: void __thiscall ArgumentList::argsToStringlist(int,char * * const)" (?argsToStringlist@ArgumentList@@QAEXHQAPAD@Z) referenced in function "public: __thiscall ArgumentList::ArgumentList(int,char * * const)" (??0ArgumentList@@QAE@HQAPAD@Z)    codevisitor-test.obj    Question1
Error   6   error LNK2019: unresolved external symbol "public: __thiscall FileVisitor::FileVisitor(class QString,bool,bool)" (??0FileVisitor@@QAE@VQString@@_N1@Z) referenced in function "public: __thiscall CodeVisitor::CodeVisitor(class QString,bool)" (??0CodeVisitor@@QAE@VQString@@_N@Z)    codevisitor-test.obj    Question1
Error   7   error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall FileVisitor::metaObject(void)const " (?metaObject@FileVisitor@@UBEPBUQMetaObject@@XZ)  codevisitor-test.obj    Question1
Error   8   error LNK2001: unresolved external symbol "public: virtual void * __thiscall FileVisitor::qt_metacast(char const *)" (?qt_metacast@FileVisitor@@UAEPAXPBD@Z)    codevisitor-test.obj    Question1
Error   9   error LNK2001: unresolved external symbol "public: virtual int __thiscall FileVisitor::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@FileVisitor@@UAEHW4Call@QMetaObject@@HPAPAX@Z)   codevisitor-test.obj    Question1
Error   10  error LNK2001: unresolved external symbol "protected: virtual bool __thiscall FileVisitor::skipDir(class QDir const &)" (?skipDir@FileVisitor@@MAE_NABVQDir@@@Z)    codevisitor-test.obj    Question1
Error   11  fatal error LNK1120: 10 unresolved externals    ... \Visual Studio 2008\Projects\Assignment1\Question1\Question1\Debug\Question1.exe    Question1

The code is as follows:

#include "argumentlist.h"
#include <codevisitor.h>
#include <QDebug>

void usage(QString appname) {
    qDebug() << appname << " Usage: \n"
         << "codevisitor [-r] [-d startdir] [-f filter] [file-list]\n"
         << "\t-r        \tvisitor will recurse into subdirs\n"
         << "\t-d startdir\tspecifies starting directory\n"
         << "\t-f filter\tfilename filter to restrict visits\n"
         << "\toptional list of files to be visited";
}

int main(int argc, char** argv) {
    ArgumentList al(argc, argv);
    QString appname = al.takeFirst(); /* app name is always first in the list. */
    if (al.count() == 0) {
        usage(appname);
        exit(1);
    }
    bool recursive(al.getSwitch("-r"));
    QString startdir(al.getSwitchArg("-d"));
    QString filter(al.getSwitchArg("-f"));
    CodeVisitor cvis(filter, recursive);
    if (startdir != QString()) {
        cvis.processEntry(startdir);
    }
    else if (al.size()) {
        cvis.processFileList(al);
    }
    else
        return 1;
    qDebug() << "Files Processed: %d" << cvis.getNumFiles();
    qDebug() << cvis.getResultString();
    return 0;
}

Thanks in advance, I'm simply stumped.

+4  A: 

Make sure your project file includes the *.cpp files containing definitions of FileVisitor and ArgumentList class' functions as indicated by the errors. Also, as Kotti suggested, if the definitions of the functions are in a library file, make sure you linked that lib file to your project.

Donotalo
Thanks Don, it wasn't the only error down the line, but helped me. Thanks a ton!
Kyle Rozendo