首页| 论坛| 消息

标题:qt&vc2005
作者:kongzhongzhe
日期:2007-03-08 14:05
内容:

qt4编译已通过
然而,编写的简单程序链接的时候却出了很多错误
好像library,directories都没有错啊
程序如下
#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}
错误如下:
Linking...
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::show(void)" (__imp_?show@QWidget@@QAEXXZ) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)" (__imp_??1QString@@QAE@XZ) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QLabel::QLabel(class QString const &,class QWidget *,class QFlags)" (__imp_??0QLabel@@QAE@ABVQString@@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::QString(char const *)" (__imp_??0QString@@QAE@PBD@Z) referenced in function _main
test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QAE@AAHPAPADH@Z) referenced in function _main
test.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaOb ..


#1 [XChinux 03-08 18:09]
应该是要链接的库没有加上的原因吧。
#2 [kongzhongzhe 03-08 22:42]
已加上
呵呵
确实忘记了
但是只要添加了q_object那个宏又不行了
obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall FindDialog::qt_metacast(char const *)" (?qt_metacast@FindDialog@@UAEPAXPBD@Z)
finddialog.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall FindDialog::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@FindDialog@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
finddialog.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const FindDialog::staticMetaObject" (?staticMetaObject@FindDialog@@2UQMetaObject@@B)
finddialog.obj : error LNK2019: unresolved external symbol "protected: void __thiscall FindDialog::findNext(class QString const &,enum Qt::CaseSensitivity)" (?findNext@FindDialog@@IAEXABVQString@@W4CaseSensitivity@Qt@@@Z) referenced in function "private: void __thiscall FindDialog::findClicked(void)" (?findClicked@FindDialog@@AAEXXZ)
finddialog.obj : error LNK2019: unresolved external symbol "protected: void __thiscall FindDialog::findPrevious(class QString const &,enum Qt::CaseSensitivity)" (?findPrevious@FindDialog@@IAEXABVQString@@W4CaseSensitivity@Qt@@@Z) referenced in function "private: void __thiscall FindDialog::findClicked(void)" (?findClicked@FindDialog@@AAEXXZ)
C:\QTTest\qt_test\Debug\qt_test.exe : fatal error LNK1120: 6 unresolved externals
#3 [XChinux 03-08 22:45]
把你的源代码和工程文件内容都帖出来吧
#4 [kongzhongzhe 03-08 22:48]
谢谢版主关心
搞定了
哈哈
把 nmake生成的 moc_*.cpp
加入工程中就可以在vc2005中 编译调试了

回复 发表
主题 版块