在Visual Studio 2005里面写了第一个Qt4的例子,就出问题了。
代码很简单,跟书上的一样:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
return 0;
}
链接时出现错误:
Main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _main
Main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)" (__imp_??1QString@@QAE@XZ) referenced in function _main
肯定是VS2005找不到QApplication的库(QtApplication.lib) 了
库已经编译安装好,没有问题。QTDIR和PATH也按照要求设置了。
最后终于发现,需要在项目属性里加入QtCore4.lib 和 QtGui4.lib。Properties->Configuration Properties->Linker->Input->Additional Depencies。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/googling/archive/2008/01/16/2046133.aspx