Hi! Please forgive me, but I am a complete newbie with Qt and am having silly troubles. I have downloaded Qt 5.0.2 and installed it on my Windows XP laptop. The installation is the default, and includes MinGW. I have the book “C++ GUI Programming with Qt4” (yes, 4, not 5), and I am trying to get the first simple test program to go. The code in “hello.cpp” is:
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel(“Hello Qt!”);
label->show();
return app.exec();
}
I have learned to make it <QtWidgets/QApplication>, not <QApplication>, etc.
I have run qmake -project to get hello.pro, which is:
######################################################################
Automatically generated by qmake (3.0) Wed 19. Jun 18:52:41 2013
######################################################################
TEMPLATE = app
TARGET = hello
INCLUDEPATH += .
Input
SOURCES += hello.cpp
Then “qmake hello.pro” seems to run successfully (or at least silently).
I have learned that I need to set up a file “make.bat” that says:
@echo off
mingw32-make %*
Having done that I get the following errors on running “make”
E:\hello>make
mingw32-make -f Makefile.Release
mingw32-make1: Entering directory ‘E:/hello’
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\hello.exe release/hello.o -lmingw32 -lqtmain -LE:\Qt-5.0.2\5.0.2\mingw47_32\lib -lQt5Gui -lQt5Core -llibEGL -llibGLESv2 -lgdi32 -luser32
release/hello.o:hello.cpp:(.text+0×59): undefined reference to `_imp___ZN12QApplicationC1ERiPPci’
release/hello.o:hello.cpp:(.text+0xbe): undefined reference to imp__ZN6QLabelC1ERK7QStringP7QWidget6QFlagsIN2Qt10WindowTypeEE’
release/hello.o:hello.cpp:(.text+0xfe): undefined reference to `_imp___ZN7QWidget4showEv’
release/hello.o:hello.cpp:(.text+0×10c): undefined reference to `_imp___ZN12QApplication4execEv’
release/hello.o:hello.cpp:(.text+0×122): undefined reference to `_imp___ZN12QApplicationD1Ev’
release/hello.o:hello.cpp:(.text+0×1be): undefined reference to `_imp___ZN12QApplicationD1Ev’
collect2.exe: error: ld returned 1 exit status
Makefile.Release:77: recipe for target ‘release\hello.exe’ failed
mingw32-make1: *** [release\hello.exe] Error 1
mingw32-make1: Leaving directory ‘E:/hello’
makefile:34: recipe for target ‘release’ failed
mingw32-make: *** [release] Error 2
**********
I am running all this from a Command prompt on my Windows XP laptop. The PATH is:
PATH=E:\Qt-5.0.2\5.0.2\mingw47_32\bin;E:\Qt-5.0.2/Tools/MinGW\bin;C:\DOS\BIN;C:\MinGW\bin;C:\DOS\CL;C:\DOS\EMACS;C:\WINDOWS;C:\WINDOWS\SYSTEM32;C:\GNUPLOT\BIN
I would be very grateful if someone would take the time to tell me, using simple words, how I could get this test program to work. It is safe to assume that I know nothing, so please be very clear what has to be done.
Thanks!
Martin
↧