PDA

View Full Version : Elementary "hello" program doesn't build



DrunkenUFOPilot
9th March 2011, 23:25
I have Qt4.3 installed on my at-work machine, and it's used for our main software development. Our builds run fine.

Today, wanting to learn more about Qt4, I'm building the very simple "hello world" demo app in Chap. 1 of the Blanchette-Summerfield book. It looks the same as in other books and online tutorials, as far as I can see, except mine is named 'hey' instead of 'hello' (too busy to type longwinded 5-letter names :P).

But in my case this won't build. I ran 'qmake -project' and have the resulting .pro file in a text editor. Then I run qmake (no args) then make. Sometimes I get this error:

bash> make
g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib64/qt-3.3/mkspecs/default -I. -I. -I/usr/lib64/qt-3.3/include -o hey.o hey.cpp
hey.cpp:4:24: error: QApplication: No such file or directory
hey.cpp:5:18: error: QLabel: No such file or directory
... subsequent errors due to no finding Qt's include files...

but sometimes I get this error:

bash> make
g++ -o hey hey.o -L/usr/lib64/qt-3.3/lib -lqt-mt -lXext -lX11 -lm
hey.o: In function `main':
/users/dwilson/play/qtblanchette/hey/hey.cpp:10: undefined reference to `QApplication::QApplication(int&, char**, int)'
hey.o: In function `QString':
/usr/include/QtCore/qstring.h:376: undefined reference to `QString::fromAscii_helper(char const*, int)'
... several more undef refs ...

What bonehead beginner mistake am I making?

wysota
9th March 2011, 23:27
Looks like you are using qmake from Qt 3.3 and not Qt 4.

DrunkenUFOPilot
10th March 2011, 00:08
Both Qt4 and Qt3 are on this machine. Well then, how to tell qmake to use 4 not 3?

nish
10th March 2011, 04:23
Both Qt4 and Qt3 are on this machine. Well then, how to tell qmake to use 4 not 3?

try to use qt4-qmake instead of qmake or install the sdk, and run qmake from full path, eg ~/qtsdk/qt/bin/qmake.

wysota
10th March 2011, 09:37
Both Qt4 and Qt3 are on this machine. Well then, how to tell qmake to use 4 not 3?

You don't "tell" qmake to use Qt4. You have two qmake binaries - one for Qt3 and one for Qt4. The proper one can be called qmake-qt4.