Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] Qt bug???

59 views
Skip to first unread message

Michael Sullivan

unread,
Jan 18, 2005, 6:20:12 PM1/18/05
to
I don't know if this is a bug in Qt or not. I re-emerged qt-3.3.3 last
night to have it install the documentation. Now the HTML docs are
installed. I've been giving my wife C++ lessons in our spare time, and
I thought she might enjoy doing some GUI stuff. I've always used Qt for
my C++ GUI projects, though I haven't worked on any since I came to
Gentoo. I typed in this program straight out of my Qt 3 book:

#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}

I ran qmake -project to get a .pro file, then qmake again to generate a
Makefile. Then I ran make and got this output:

g++ -c -pipe -Wall -W -O2 -march=i686 -DQT_NO_DEBUG
-I/usr/qt/3/mkspecs/linux-g++ -I. -I. -I/usr/qt/3/include -o helloqt.o
helloqt.cpp
g++ -o qt helloqt.o -L/usr/X11R6/lib -lXext -lX11 -lm
helloqt.o(.text+0x2a): In function `main':
: undefined reference to `QApplication::QApplication[in-charge](int&,
char**)'
helloqt.o(.text+0x50): In function `main':
: undefined reference to `QString::QString[in-charge](char const*)'
helloqt.o(.text+0x6e): In function `main':
: undefined reference to `QLabel::QLabel[in-charge](QString const&,
QWidget*, char const*, unsigned)'
helloqt.o(.text+0x84): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0x8e): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.text+0x9a): In function `main':
: undefined reference to `QApplication::setMainWidget(QWidget*)'
helloqt.o(.text+0xad): In function `main':
: undefined reference to `QApplication::exec()'
helloqt.o(.text+0xb7): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
helloqt.o(.text+0xe0): In function `main':
: undefined reference to `QString::shared_null'
helloqt.o(.text+0xea): In function `main':
: undefined reference to `QStringData::deleteSelf()'
helloqt.o(.text+0x104): In function `main':
: undefined reference to `QApplication::~QApplication [in-charge]()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0xc): undefined reference to
`QGList::clear()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x10): undefined reference to
`QGList::~QGList [in-charge]()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x14): undefined reference to
`QGList::~QGList [in-charge deleting]()'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x18): undefined reference to
`QPtrCollection::newItem(void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x20): undefined reference to
`QGList::compareItems(void*, void*)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x24): undefined reference to
`QGList::read(QDataStream&, void*&)'
helloqt.o(.gnu.linkonce.r._ZTV6QGList+0x28): undefined reference to
`QGList::write(QDataStream&, void*) const'
helloqt.o(.gnu.linkonce.r._ZTI6QGList+0x8): undefined reference to
`typeinfo for QPtrCollection'
collect2: ld returned 1 exit status
make: *** [qt] Error 1

I looked over my book's source code and compared it to what I typed in
and they look identical. Is this a problem with my source code or a
problem with the Qt toolkit? Should I submit this as a bug?


--
gento...@gentoo.org mailing list

Jerry McBride

unread,
Jan 18, 2005, 8:00:19 PM1/18/05
to
On Tuesday 18 January 2005 06:15 pm, Michael Sullivan wrote:
> I don't know if this is a bug in Qt or not. I re-emerged qt-3.3.3 last
> night to have it install the documentation. Now the HTML docs are
> installed. I've been giving my wife C++ lessons in our spare time, and
> I thought she might enjoy doing some GUI stuff.

Man... i've heard it all now..... :')


--

******************************************************************************
Registered Linux User Number 185956
FSF Associate Member number 2340 since 05/20/2004
Join me in chat at #linux-users on irc.freenode.net
Buy an Xbox for $149.00, run linux on it and Microsoft loses $150.00!
7:42pm up 101 days, 3:28, 8 users, load average: 0.10, 0.14, 0.09

--
gento...@gentoo.org mailing list

Andy Herrman

unread,
Jan 18, 2005, 8:40:08 PM1/18/05
to
On Tue, 18 Jan 2005 17:15:36 -0600, Michael Sullivan
<mic...@espersunited.com> wrote:
> I looked over my book's source code and compared it to what I typed in
> and they look identical. Is this a problem with my source code or a
> problem with the Qt toolkit? Should I submit this as a bug?
>

Before that, try a sanity check. Open up the makefile and make sure
it's including the right libraries and that the paths are all correct.
It's possible some config file got messed up when you emerged it and
the paths aren't right. It looks like a linker error, so maybe it's
not pulling in the right libraries.

-Andy

--
gento...@gentoo.org mailing list

Gabriel M. Beddingfield

unread,
Jan 18, 2005, 9:10:08 PM1/18/05
to
Michael Sullivan wrote:

> installed. I've been giving my wife C++ lessons in our spare time, and

And she listens? Wow. I can't even get my wife to dust off her flute to
play with me... much less get her interested in computers!

> I ran qmake -project to get a .pro file, then qmake again to generate a
> Makefile. Then I ran make and got this output:

Don't you have to put the project in the qmake statement? 'qmake foo.pro'

> g++ -o qt helloqt.o -L/usr/X11R6/lib -lXext -lX11 -lm

^^^^^^^^^^^^^^^^

Here's your problem. You should see '-lqt' in there somewhere.

Why is it not there? I'm not sure. Do you have several makefiles in the
same directory (makefile, Makefile, GNUMakefile, GNUmakefile, etc). Maybe
you're up against precedence. Someone suggested looking through the qmake
generated makefile. You should see this line:

LIBS = $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm

> I looked over my book's source code and compared it to what I typed in
> and they look identical. Is this a problem with my source code or a
> problem with the Qt toolkit? Should I submit this as a bug?

Doubt it. Check around some more to see if there's something you're doing.
I couldn't recreate the bug here. The -lqt shows up in the makefile and
everything builds just fine.

For me:
$ qmake --version
Qmake version: 1.07a (Qt 3.3.3)
Qmake is free software from Trolltech AS.
$ uname -a
Linux orion 2.6.9-gentoo-r13 #3 Mon Jan 3 17:53:22 CST 2005 i686 Intel(R)
Pentium(R) M processor 1.60GHz GenuineIntel GNU/Linux
$ g++ --version
g++ (GCC) 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ make --version
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
$

HTH!

--
G a b r i e l M . B e d d i n g f i e l d


--
gento...@gentoo.org mailing list

Gabriel M. Beddingfield

unread,
Jan 18, 2005, 10:50:05 PM1/18/05
to
<posted & mailed>

Gabriel M. Beddingfield wrote:

> I couldn't recreate the bug here. The -lqt shows up in the makefile and
> everything builds just fine.

Aha! I stand corrected. The problem is that your project directory is
called 'qt'. Change to something else ('qt', 'foo', 'mustard') and your
problem will go away.

Whether you report this as a bug is up to you. It's either a bug or an
undocumented feature. ;-)

The following script will recreate the error if you run it without
arguments.

#!/bin/bash

#
# Script to test out qt.
# g. m. beddingfield <gab...@teuton.org>
# 18JAN2005
#

#
# To repeat issue submitted by Michael Sullivan on gentoo-user
# list (1/18/05), run this script with no arguments:
#
# ./qttest.sh
#
# To work around the issue, run this script with an argument:
#
# ./qttest.sh foo
#
# The problem is that the project directory's name is 'qt'.
# Whether this is a bug or 'feature' depends on Trolltech.
#

TMPDIR=__QT_TMP_DIR
if [ -z $1 ]; then
APPDIR=qt
else
APPDIR=$1
fi

mkdir $TMPDIR
cd $TMPDIR
mkdir $APPDIR
cd $APPDIR
cat > foo.cpp <<EOF

#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QLabel *label = new QLabel("Hello World!", 0);
app.setMainWidget(label);
label->show();
return app.exec();
}

EOF
qmake -project && qmake && make && ./$APPDIR && echo "It worked. :-)"

#
# END OF SCRIPT
#

Michael Sullivan

unread,
Jan 19, 2005, 12:00:13 AM1/19/05
to
You were right. The directory it was in was called qt. I never would
have thought that that would cause the compile to fail. Seems pretty
stupid to me. I renamed the directory qtStuff and it compiled and
linked just fine. Thanks!
-Michael Sullivan-


--
gento...@gentoo.org mailing list

Gabriel M. Beddingfield

unread,
Jan 19, 2005, 8:00:18 AM1/19/05
to
Michael Sullivan wrote:

> You were right. The directory it was in was called qt. I never would
> have thought that that would cause the compile to fail. Seems pretty
> stupid to me. I renamed the directory qtStuff and it compiled and
> linked just fine. Thanks!
> -Michael Sullivan-

I'm guessing it's a "feature" so that QT developers can put their project in
a directory called 'qt' and then qmake won't try to link the project
against the qt libraries (since the project is supposed to *build* the qt
libraries).

Still, a pitfall like that should at least generate a warning.

0 new messages