gpt4 book ai didi

c++ - Qt 链接器错误

转载 作者:行者123 更新时间:2023-11-30 02:11:50 24 4
gpt4 key购买 nike

我一直在努力让 Qt 工作(QCreator、QIde 和现在的 VS2008)。

我已经解决了很多问题,但我现在面临以下构建错误,坦率地说,我没有想法。

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

代码如下:

#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;
}

提前致谢,我只是被难住了。

最佳答案

确保您的项目文件包含 *.cpp 文件,其中包含错误指示的 FileVisitorArgumentList 类函数的定义。另外,正如 Kotti 所建议的,如果函数的定义在库文件中,请确保将该库文件链接到您的项目。

关于c++ - Qt 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2750509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com