在Qt4+vs.net中新建Qt Console Application项目(选择Qt3 Support)
源程序如下:
#ifndef QT3_SUPPORT
#define QT3_SUPPORT
#include <Qt/qapplication.h>
#include <Qt/qlabel.h>
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
QLabel *label = new QLabel("Hello Qt!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}
#endif
编译错误如下:
正在链接...
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual int __thiscall QWidget::metric(enum QPaintDevice::PaintDeviceMetric)const " (?metric@QWidget@@MBEHW4PaintDeviceMetric@QPaintDevice@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall QWidget::releaseDC(struct HDC__ *)const " (?releaseDC@QWidget@@UBEXPAUHDC__@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct HDC__ * __thiscall QWidget::getDC(void)const " (?getDC@QWidget@@UBEPAUHDC__@@XZ)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QPaintEngine * __thiscall QWidget::paintEngine(void)const " (?paintEngine@QWidget@@UBEPAVQPaintEngine@@XZ)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall QWidget::devType(void)const " (?devType@QWidget@@UBEHXZ)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::languageChange(void)" (?languageChange@QWidget@@MAEXXZ)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::windowActivationChange(bool)" (?windowActivationChange@QWidget@@MAEX_N@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::fontChange(class QFont const &)" (?fontChange@QWidget@@MAEXABVQFont@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::paletteChange(class QPalette const &)" (?paletteChange@QWidget@@MAEXABVQPalette@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::enabledChange(bool)" (?enabledChange@QWidget@@MAEX_N@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::styleChange(class QStyle &)" (?styleChange@QWidget@@MAEXAAVQStyle@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __thiscall QWidget::focusNextPrevChild(bool)" (?focusNextPrevChild@QWidget@@MAE_N_N@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QVariant __thiscall QWidget::inputMethodQuery(enum Qt::InputMethodQuery)const " (?inputMethodQuery@QWidget@@UBE?AVQVariant@@W4InputMethodQuery@Qt@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::inputMethodEvent(class QInputMethodEvent *)" (?inputMethodEvent@QWidget@@MAEXPAVQInputMethodEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QLabel::changeEvent(class QEvent *)" (?changeEvent@QLabel@@MAEXPAVQEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __thiscall QWidget::winEvent(struct tagMSG *,long *)" (?winEvent@QWidget@@MAE_NPAUtagMSG@@PAJ@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::hideEvent(class QHideEvent *)" (?hideEvent@QWidget@@MAEXPAVQHideEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::showEvent(class QShowEvent *)" (?showEvent@QWidget@@MAEXPAVQShowEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::dropEvent(class QDropEvent *)" (?dropEvent@QWidget@@MAEXPAVQDropEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent@QWidget@@MAEXPAVQDragLeaveEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent@QWidget@@MAEXPAVQDragMoveEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent@QWidget@@MAEXPAVQDragEnterEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::actionEvent(class QActionEvent *)" (?actionEvent@QWidget@@MAEXPAVQActionEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::tabletEvent(class QTabletEvent *)" (?tabletEvent@QWidget@@MAEXPAVQTabletEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent@QWidget@@MAEXPAVQContextMenuEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::closeEvent(class QCloseEvent *)" (?closeEvent@QWidget@@MAEXPAVQCloseEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QWidget@@MAEXPAVQResizeEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QWidget@@MAEXPAVQMoveEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QLabel::paintEvent(class QPaintEvent *)" (?paintEvent@QLabel@@MAEXPAVQPaintEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::leaveEvent(class QEvent *)" (?leaveEvent@QWidget@@MAEXPAVQEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::enterEvent(class QEvent *)" (?enterEvent@QWidget@@MAEXPAVQEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QWidget@@MAEXPAVQFocusEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::focusInEvent(class QFocusEvent *)" (?focusInEvent@QWidget@@MAEXPAVQFocusEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QWidget@@MAEXPAVQKeyEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QWidget@@MAEXPAVQKeyEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::wheelEvent(class QWheelEvent *)" (?wheelEvent@QWidget@@MAEXPAVQWheelEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QWidget::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall QLabel::heightForWidth(int)const " (?heightForWidth@QLabel@@UBEHH@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QSize __thiscall QLabel::minimumSizeHint(void)const " (?minimumSizeHint@QLabel@@UBE?AVQSize@@XZ)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual class QSize __thiscall QLabel::sizeHint(void)const " (?sizeHint@QLabel@@UBE?AVQSize@@XZ)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall QWidget::setVisible(bool)" (?setVisible@QWidget@@UAEX_N@Z)
main.obj : error LNK2001: 无法解析的外部符号 "protected: virtual bool __thiscall QLabel::event(class QEvent *)" (?event@QLabel@@MAE_NPAVQEvent@@@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall QLabel::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QLabel@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall QLabel::qt_metacast(char const *)" (?qt_metacast@QLabel@@UAEPAXPBD@Z)
main.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall QLabel::metaObject(void)const " (?metaObject@QLabel@@UBEPBUQMetaObject@@XZ)
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall QWidget::show(void)" (__imp_?show@QWidget@@QAEXXZ) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static void __cdecl QApplication::setMainWidget(class QWidget *)" (__imp_?setMainWidget@QApplication@@SAXPAVQWidget@@@Z) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__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) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *)" (__imp_??0QApplication@@QAE@AAHPAPAD@Z) ,该符号在函数 _main 中被引用
main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall QLabel::~QLabel(void)" (__imp_??1QLabel@@UAE@XZ) ,该符号在函数 "public: virtual void * __thiscall QLabel::`scalar deleting destructor'(unsigned int)" (??_GQLabel@@UAEPAXI@Z) 中被引用
E:\qt\study\qt3study\helloworld\Debug\helloworld.exe : fatal error LNK1120: 55 个无法解析的外部命令
生成日志保存在“file://e:\qt\study\qt3study\helloworld\Debug\BuildLog.htm”中
helloworld - 56 错误,0 警告
---------------------- 完成 ---------------------
生成: 0 已成功, 1 已失败, 0 已跳过
[ 此贴被XChinux在2005-11-29 16:41重新编辑 ]