1. 安装qt-win-opensource-4.6.0-vs2008.exe
2. 安装qt-vs-addin-1.1.2.exe
3. 设置Path, c:/qt/2.6.0/bin, 设置QTDIR, c:/qt/2.6.0
4, 在vs2008 menu->tools->options->Projects and Solutions->VC++ Directions中添加
a. include files:C:\Qt\4.6.0\include
b. library files:C:\Qt\4.6.0\lib
5, 创建一个win32 console application, 代码如下:
#include "stdafx.h"
#include <QtGUI/QApplication>
#include <QtGUI/QLabel>
int _tmain(int argc, char* argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}
6,编译没有问题
7,链接出错,错误如下,请高手指点,谢谢。
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _wmain TestQT.obj TestQT
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function _wmain TestQT.obj TestQT
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::show(void)" (__imp_?show@QWidget@@QAEXXZ) referenced in function _wmain TestQT.obj TestQT
Error 4 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)" (__imp_??1QString@@QAE@XZ) referenced in function _wmain TestQT.obj TestQT
Error 5 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QLabel::QLabel(class QString const &,class QWidget *,class QFlags<enum Qt::WindowType>)" (__imp_??0QLabel@@QAE@ABVQString@@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function _wmain TestQT.obj TestQT
Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::QString(char const *)" (__imp_??0QString@@QAE@PBD@Z) referenced in function _wmain TestQT.obj TestQT
Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QAE@AAHPAPADH@Z) referenced in function _wmain TestQT.obj TestQT
Error 8 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QLabel::metaObject(void)const " (?metaObject@QLabel@@UBEPBUQMetaObject@@XZ) TestQT.obj TestQT
Error 9 error LNK2001: unresolved external symbol "public: virtual void * __thiscall QLabel::qt_metacast(char const *)" (?qt_metacast@QLabel@@UAEPAXPBD@Z) TestQT.obj TestQT
Error 10 error LNK2001: unresolved external symbol "public: virtual int __thiscall QLabel::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QLabel@@UAEHW4Call@QMetaObject@@HPAPAX@Z) TestQT.obj TestQT
Error 11 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QLabel::event(class QEvent *)" (?event@QLabel@@MAE_NPAVQEvent@@@Z) TestQT.obj TestQT
Error 12 error LNK2001: unresolved external symbol "public: virtual bool __thiscall QObject::eventFilter(class QObject *,class QEvent *)" (?eventFilter@QObject@@UAE_NPAV1@PAVQEvent@@@Z) TestQT.obj TestQT
Error 13 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QObject::timerEvent(class QTimerEvent *)" (?timerEvent@QObject@@MAEXPAVQTimerEvent@@@Z) TestQT.obj TestQT
Error 14 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QObject::childEvent(class QChildEvent *)" (?childEvent@QObject@@MAEXPAVQChildEvent@@@Z) TestQT.obj TestQT
Error 15 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QObject::customEvent(class QEvent *)" (?customEvent@QObject@@MAEXPAVQEvent@@@Z) TestQT.obj TestQT
Error 16 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QObject::connectNotify(char const *)" (?connectNotify@QObject@@MAEXPBD@Z) TestQT.obj TestQT
Error 17 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QObject::disconnectNotify(char const *)" (?disconnectNotify@QObject@@MAEXPBD@Z) TestQT.obj TestQT
Error 18 error LNK2001: unresolved external symbol "public: virtual void __thiscall QWidget::setVisible(bool)" (?setVisible@QWidget@@UAEX_N@Z) TestQT.obj TestQT
Error 19 error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QLabel::sizeHint(void)const " (?sizeHint@QLabel@@UBE?AVQSize@@XZ) TestQT.obj TestQT
Error 20 error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QLabel::minimumSizeHint(void)const " (?minimumSizeHint@QLabel@@UBE?AVQSize@@XZ) TestQT.obj TestQT
Error 21 error LNK2001: unresolved external symbol "public: virtual int __thiscall QLabel::heightForWidth(int)const " (?heightForWidth@QLabel@@UBEHH@Z) TestQT.obj TestQT
Error 22 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QLabel@@MAEXPAVQMouseEvent@@@Z) TestQT.obj TestQT
Error 23 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QLabel@@MAEXPAVQMouseEvent@@@Z) TestQT.obj TestQT
Error 24 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QWidget@@MAEXPAVQMouseEvent@@@Z) TestQT.obj TestQT
Error 25 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QLabel@@MAEXPAVQMouseEvent@@@Z) TestQT.obj TestQT
Error 26 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::wheelEvent(class QWheelEvent *)" (?wheelEvent@QWidget@@MAEXPAVQWheelEvent@@@Z) TestQT.obj TestQT
Error 27 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QLabel@@MAEXPAVQKeyEvent@@@Z) TestQT.obj TestQT
Error 28 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QWidget@@MAEXPAVQKeyEvent@@@Z) TestQT.obj TestQT
Error 29 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::focusInEvent(class QFocusEvent *)" (?focusInEvent@QLabel@@MAEXPAVQFocusEvent@@@Z) TestQT.obj TestQT
Error 30 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QLabel@@MAEXPAVQFocusEvent@@@Z) TestQT.obj TestQT
Error 31 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::enterEvent(class QEvent *)" (?enterEvent@QWidget@@MAEXPAVQEvent@@@Z) TestQT.obj TestQT
Error 32 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::leaveEvent(class QEvent *)" (?leaveEvent@QWidget@@MAEXPAVQEvent@@@Z) TestQT.obj TestQT
Error 33 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::paintEvent(class QPaintEvent *)" (?paintEvent@QLabel@@MAEXPAVQPaintEvent@@@Z) TestQT.obj TestQT
Error 34 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QWidget@@MAEXPAVQMoveEvent@@@Z) TestQT.obj TestQT
Error 35 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QWidget@@MAEXPAVQResizeEvent@@@Z) TestQT.obj TestQT
Error 36 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::closeEvent(class QCloseEvent *)" (?closeEvent@QWidget@@MAEXPAVQCloseEvent@@@Z) TestQT.obj TestQT
Error 37 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent@QLabel@@MAEXPAVQContextMenuEvent@@@Z) TestQT.obj TestQT
Error 38 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::tabletEvent(class QTabletEvent *)" (?tabletEvent@QWidget@@MAEXPAVQTabletEvent@@@Z) TestQT.obj TestQT
Error 39 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::actionEvent(class QActionEvent *)" (?actionEvent@QWidget@@MAEXPAVQActionEvent@@@Z) TestQT.obj TestQT
Error 40 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent@QWidget@@MAEXPAVQDragEnterEvent@@@Z) TestQT.obj TestQT
Error 41 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent@QWidget@@MAEXPAVQDragMoveEvent@@@Z) TestQT.obj TestQT
Error 42 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent@QWidget@@MAEXPAVQDragLeaveEvent@@@Z) TestQT.obj TestQT
Error 43 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::dropEvent(class QDropEvent *)" (?dropEvent@QWidget@@MAEXPAVQDropEvent@@@Z) TestQT.obj TestQT
Error 44 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::showEvent(class QShowEvent *)" (?showEvent@QWidget@@MAEXPAVQShowEvent@@@Z) TestQT.obj TestQT
Error 45 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::hideEvent(class QHideEvent *)" (?hideEvent@QWidget@@MAEXPAVQHideEvent@@@Z) TestQT.obj TestQT
Error 46 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWidget::winEvent(struct tagMSG *,long *)" (?winEvent@QWidget@@MAE_NPAUtagMSG@@PAJ@Z) TestQT.obj TestQT
Error 47 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QLabel::changeEvent(class QEvent *)" (?changeEvent@QLabel@@MAEXPAVQEvent@@@Z) TestQT.obj TestQT
Error 48 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::inputMethodEvent(class QInputMethodEvent *)" (?inputMethodEvent@QWidget@@MAEXPAVQInputMethodEvent@@@Z) TestQT.obj TestQT
Error 49 error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QWidget::inputMethodQuery(enum Qt::InputMethodQuery)const " (?inputMethodQuery@QWidget@@UBE?AVQVariant@@W4InputMethodQuery@Qt@@@Z) TestQT.obj TestQT
Error 50 error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QLabel::focusNextPrevChild(bool)" (?focusNextPrevChild@QLabel@@MAE_N_N@Z) TestQT.obj TestQT
Error 51 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::styleChange(class QStyle &)" (?styleChange@QWidget@@MAEXAAVQStyle@@@Z) TestQT.obj TestQT
Error 52 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::enabledChange(bool)" (?enabledChange@QWidget@@MAEX_N@Z) TestQT.obj TestQT
Error 53 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::paletteChange(class QPalette const &)" (?paletteChange@QWidget@@MAEXABVQPalette@@@Z) TestQT.obj TestQT
Error 54 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::fontChange(class QFont const &)" (?fontChange@QWidget@@MAEXABVQFont@@@Z) TestQT.obj TestQT
Error 55 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::windowActivationChange(bool)" (?windowActivationChange@QWidget@@MAEX_N@Z) TestQT.obj TestQT
Error 56 error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::languageChange(void)" (?languageChange@QWidget@@MAEXXZ) TestQT.obj TestQT
Error 57 error LNK2001: unresolved external symbol "public: virtual int __thiscall QWidget::devType(void)const " (?devType@QWidget@@UBEHXZ) TestQT.obj TestQT
Error 58 error LNK2001: unresolved external symbol "public: virtual class QPaintEngine * __thiscall QWidget::paintEngine(void)const " (?paintEngine@QWidget@@UBEPAVQPaintEngine@@XZ) TestQT.obj TestQT
Error 59 error LNK2001: unresolved external symbol "public: virtual struct HDC__ * __thiscall QWidget::getDC(void)const " (?getDC@QWidget@@UBEPAUHDC__@@XZ) TestQT.obj TestQT
Error 60 error LNK2001: unresolved external symbol "public: virtual void __thiscall QWidget::releaseDC(struct HDC__ *)const " (?releaseDC@QWidget@@UBEXPAUHDC__@@@Z) TestQT.obj TestQT
Error 61 error LNK2001: unresolved external symbol "protected: virtual int __thiscall QWidget::metric(enum QPaintDevice::PaintDeviceMetric)const " (?metric@QWidget@@MBEHW4PaintDeviceMetric@QPaintDevice@@@Z) TestQT.obj TestQT
Error 62 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QLabel::~QLabel(void)" (__imp_??1QLabel@@UAE@XZ) referenced in function "public: virtual void * __thiscall QLabel::`scalar deleting destructor'(unsigned int)" (??_GQLabel@@UAEPAXI@Z) TestQT.obj TestQT
Error 63 fatal error LNK1120: 62 unresolved externals E:\Test Solutions\TestQT\Debug\TestQT.exe TestQT