PDA

View Full Version : Setting up qmake to run "Hello World"



Rolsch
27th May 2006, 01:31
Hi,

I have a problem compiling my first "Hello World" program with qmake. I am using QT 3.3.4 with Debian Sarge and gcc 3.3.5. I first compiled the Qt-Tutorial 1 from the Trolltech website by directly calling gcc without any problems:


gcc -o qt1 main.cpp -I$QTDIR/include -L$QTDIR/lib -lqt-mt

Next I wanted to follow the direction from the tutorial and use qmake:


qmake -project
qmake
make

The last call to make gave me a long list of errors:

g++ -o qt main.o -L/usr/X11R6/lib -lXext -lX11 -lm
main.o(.text+0x30): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&, char**)'
main.o(.text+0x41): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
main.o(.text+0x5f): In function `main':
: undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)'
main.o(.text+0x74): In function `main':
: undefined reference to `QString::shared_null'
main.o(.text+0x7e): In function `main':
: undefined reference to `QStringData::deleteSelf()'
main.o(.text+0xa6): In function `main':
: undefined reference to `QPushButton::resize(int, int)'
main.o(.text+0xb2): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
main.o(.text+0xba): In function `main':
: undefined reference to `QWidget::show()'
main.o(.text+0xc2): In function `main':
: undefined reference to `QApplication::exec()'
main.o(.text+0xcc): In function `main':
: undefined reference to `QPushButton::~QPushButton [in-charge]()'
main.o(.text+0xd4): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
...

What makes me suspicious is the first line containing a call to gcc, using X11 libraries and not Qt libraries...

jacek
27th May 2006, 01:34
Does your project happen to be in a directory named "qt"? Add "TARGET = something" to the .pro file and run "qmake && make".

Rolsch
27th May 2006, 02:37
Thanks, it works now! The problem was just my stupid directory name... :o

Now the needed qt-library is linked correctly against my project.