首页| 论坛| 消息

标题:【提问】Qt3程序在Qt4+vs.net2003下编译的问题
作者:badboy_llf
日期:2005-11-27 10:27
内容:

在Qt4+vs.net中新建Qt Console Application项目(选择Qt3 Support)
源程序如下:
#ifndef QT3_SUPPORT
#define QT3_SUPPORT
#include
#include
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@@MAEXABVQPalet ..


#1 [XChinux 11-27 10:35]
Qt3Support是用于移植Qt3的程序的。
而不是让你在Qt4里写Qt3的程序。
#2 [badboy_llf 11-27 10:49]
多谢,又明白了一些
#3 [seraphliu 04-25 13:09]
#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
Linking...
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: virtual __thiscall QPushButton::~QPushButton(void)" (__imp_??1QPushButton@@UAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::show(void)" (__imp_?show@QWidget@@QAEXXZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::resize(int,int)" (__imp_?resize@QWidget@@QAEXHH@Z) 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
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QPushButton::QPushButton(class QString const &,class QWidget *)" (__imp_??0QPushButton@@QAE@ABVQString@@PAVQWidget@@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::QString(char const *)" (__imp_??0QString@@QAE@PBD@Z) referenced in function _main
main.obj : error LNK2019: unresolved external..
#4 [seraphliu 04-25 13:41]
还有
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: "public: __thiscall bad_cast::bad_cast(char const *)" (??0bad_cast@@QAE@PBD@Z) already defined in LIBCD.lib(stdexcpt.obj)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCD.lib(typinfo.obj)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCD.lib(typinfo.obj)
LIBCD.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/test.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://c:\Documents and Settings\seraphliu\Desktop\test\test\Debug\BuildLog.htm"
test - 4 error(s), 1 warning(s)

---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped

真是晕啊

回复 发表
主题 版块