You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, May 26th 2010, 5:43pm

unresolved external symbol in VC++ 2008 while using Qt 4.6.2

hi,
I am trying to compile this piece of code in VC++ 2008


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <QtCore/QCoreApplication>
#include <QtGui/QApplication>
#include <QtGui/QFont>
#include <QtGui/QLCDNumber>
#include <QtGui/QPushButton>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>

 class MyWidget : public QWidget
 {
 public:
 	MyWidget(QWidget *parent = 0);
 };

 MyWidget::MyWidget(QWidget *parent)
 	: QWidget(parent)
 {
 	QPushButton *quit = new QPushButton(tr("Quit"));
 	quit->setFont(QFont("Times", 18, QFont::Bold));

 	QLCDNumber *lcd = new QLCDNumber(2);
 	lcd->setSegmentStyle(QLCDNumber::Filled);

 	QSlider *slider = new QSlider(Qt::Horizontal);
 	slider->setRange(0, 99);
 	slider->setValue(0);

 	connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
 	connect(slider, SIGNAL(valueChanged(int)),
         	lcd, SLOT(display(int)));

 	QVBoxLayout *layout = new QVBoxLayout;
 	layout->addWidget(quit);
 	layout->addWidget(lcd);
 	layout->addWidget(slider);
 	setLayout(layout);
 }

 int main(int argc, char *argv[])
 {
 	QApplication app(argc, argv);
 	MyWidget widget;
 	widget.show();
 	return app.exec();
 }


Its the exact same code from the Qt tutorials page. I am able to compile it in vc++ command prompt using nmake. But when I use VC++ it gives me this long list of errors. 8o 8o 8o


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1>------ Build started: Project: qt, Configuration: Debug Win32 ------
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QWidget::~QWidget(void)" (__imp_??1QWidget@@UAE@XZ) referenced in function __unwindfunclet$??0MyWidget@@QAE@PAVQWidget@@@Z$0
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::setLayout(class QLayout *)" (__imp_?setLayout@QWidget@@QAEXPAVQLayout@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QBoxLayout::addWidget(class QWidget *,int,class QFlags<enum Qt::AlignmentFlag>)" (__imp_?addWidget@QBoxLayout@@QAEXPAVQWidget@@HV?$QFlags@W4AlignmentFlag@Qt@@@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QVBoxLayout::QVBoxLayout(void)" (__imp_??0QVBoxLayout@@QAE@XZ) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QAbstractSlider::setValue(int)" (__imp_?setValue@QAbstractSlider@@QAEXH@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QAbstractSlider::setRange(int,int)" (__imp_?setRange@QAbstractSlider@@QAEXHH@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSlider::QSlider(enum Qt::Orientation,class QWidget *)" (__imp_??0QSlider@@QAE@W4Orientation@Qt@@PAVQWidget@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QLCDNumber::setSegmentStyle(enum QLCDNumber::SegmentStyle)" (__imp_?setSegmentStyle@QLCDNumber@@QAEXW4SegmentStyle@1@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QLCDNumber::QLCDNumber(unsigned int,class QWidget *)" (__imp_??0QLCDNumber@@QAE@IPAVQWidget@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QFont::~QFont(void)" (__imp_??1QFont@@QAE@XZ) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::setFont(class QFont const &)" (__imp_?setFont@QWidget@@QAEXABVQFont@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QFont::QFont(class QString const &,int,int,bool)" (__imp_??0QFont@@QAE@ABVQString@@HH_N@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>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 "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QWidget::tr(char const *,char const *)" (__imp_?tr@QWidget@@SA?AVQString@@PBD0@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QWidget::QWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (__imp_??0QWidget@@QAE@PAV0@V?$QFlags@W4WindowType@Qt@@@@@Z) referenced in function "public: __thiscall MyWidget::MyWidget(class QWidget *)" (??0MyWidget@@QAE@PAVQWidget@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QWidget::metaObject(void)const " (?metaObject@QWidget@@UBEPBUQMetaObject@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QWidget::qt_metacast(char const *)" (?qt_metacast@QWidget@@UAEPAXPBD@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWidget::event(class QEvent *)" (?event@QWidget@@MAE_NPAVQEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QWidget::setVisible(bool)" (?setVisible@QWidget@@UAEX_N@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWidget::sizeHint(void)const " (?sizeHint@QWidget@@UBE?AVQSize@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWidget::minimumSizeHint(void)const " (?minimumSizeHint@QWidget@@UBE?AVQSize@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWidget::heightForWidth(int)const " (?heightForWidth@QWidget@@UBEHH@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QWidget@@MAEXPAVQMouseEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::wheelEvent(class QWheelEvent *)" (?wheelEvent@QWidget@@MAEXPAVQWheelEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QWidget@@MAEXPAVQKeyEvent@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWidget::keyReleaseEvent(class QKeyEvent *)" 
1>C:\Users\Manikantan Nambi\Documents\Visual Studio 2008\Projects\qt\Debug\qt.exe : fatal error LNK1120: 135 unresolved externals
1>Build log was saved at "file://c:\Users\Manikantan Nambi\Documents\Visual Studio 2008\Projects\qt\qt\Debug\BuildLog.htm"
1>qt - 136 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =====


The actual list is longer. But I have cut it short ;)

Does anyone know what the problem is ?

Thanks in advance,
Mani

2

Thursday, May 27th 2010, 11:35am

did you updated the library path with the Qt lib path and add the QTCore, QTgui in your list of library?

3

Tuesday, July 11th 2017, 7:13am

Have you found solution to this issue.
Even I am seeing same errors while I have following libs included,


qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Multimedia.lib
Qt5MultimediaWidgets.lib
Qt5Qml.lib
Qt5AxContainer.lib
Qt5AxBase.lib
Qt5Concurrent.lib
Qt5QuickWidgets.lib
Qt5WebChannel.lib
Qt5Widgets.lib
Qt5XmlPatterns.lib
Qt5Network.lib
Qt5Quick.lib
Qt5UiTools.lib
Qt5PrintSupport.lib
Qt5WebSockets.lib
Qt5WebEngineWidgets.lib