You are not logged in.

#1 2006-03-28 15:09:14

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Problem with Qt compilation

[17:05] benol ~/qt $ qmake -project
[17:06] benol ~/qt $ qmake
[17:06] benol ~/qt $ make
g++ -c -pipe -Wall -W -march=i686 -O2 -pipe -DQT_NO_DEBUG  -I/opt/qt/mkspecs/linux-g++ -I. -I. -I/opt/qt/include -o test.o test.cpp
test.cpp:15:2: warning: no newline at end of file
g++  -o qt test.o    -L/usr/X11R6/lib -lXext -lX11 -lm
test.o: In function `main':
test.cpp:(.text+0x2a): undefined reference to `QApplication::QApplication(int&, char**)'
test.cpp:(.text+0x3b): undefined reference to `QString::QString(char const*)'
test.cpp:(.text+0x59): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*, char const*)'
test.cpp:(.text+0x6b): undefined reference to `QString::shared_null'
test.cpp:(.text+0x75): undefined reference to `QStringData::deleteSelf()'
test.cpp:(.text+0x8f): undefined reference to `QPushButton::resize(int, int)'
test.cpp:(.text+0x9b): undefined reference to `QApplication::setMainWidget(QWidget*)'
test.cpp:(.text+0xa3): undefined reference to `QWidget::show()'
test.cpp:(.text+0xab): undefined reference to `QApplication::exec()'
test.cpp:(.text+0xb5): undefined reference to `QPushButton::~QPushButton()'
test.cpp:(.text+0xbd): undefined reference to `QApplication::~QApplication()'
test.cpp:(.text+0xdb): undefined reference to `QString::shared_null'
test.cpp:(.text+0xe5): undefined reference to `QStringData::deleteSelf()'
test.cpp:(.text+0xed): undefined reference to `QApplication::~QApplication()'
test.cpp:(.text+0x103): undefined reference to `QPushButton::~QPushButton()'
test.o:(.gnu.linkonce.r._ZTI6QGList[typeinfo for QGList]+0x8): undefined reference to `typeinfo for QPtrCollection'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0xc): undefined reference to `QGList::clear()'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x10): undefined reference to `QGList::~QGList()'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x14): undefined reference to `QGList::~QGList()'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x18): undefined reference to `QPtrCollection::newItem(void*)'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x20): undefined reference to `QGList::compareItems(void*, void*)'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x24): undefined reference to `QGList::read(QDataStream&, void*&)'
test.o:(.gnu.linkonce.r._ZTV6QGList[vtable for QGList]+0x28): undefined reference to `QGList::write(QDataStream&, void*) const'
collect2: ld returned 1 exit status
make: *** [qt] Error 1

Do you know what's the problem? Do I miss some kind of "dev" package or is it a bug in qt package?

Offline

#2 2006-03-28 16:45:57

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Problem with Qt compilation

What are you trying to compile?? a personal project ?? maybe this topic should be in General Programing forum...

Offline

#3 2006-03-28 16:57:52

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

Yes, it's my program, "hello world" exactly, only to try qt. I didn't notice the "general programming" forum - my bad.

So does anyone develop in Qt on Arch? What is going on?

Offline

#4 2006-03-28 18:12:17

sh__
Member
Registered: 2005-07-19
Posts: 272

Re: Problem with Qt compilation

Seems like it's failing to link against the qt libraries, probably due to missing -lqt-mt. My guess is that in the Makefile you should have something like

LDFLAGS=-lqt-mt -lXext -lX11 -lm

I'm not sure how qmake handles Makefiles, though.

Offline

#5 2006-03-28 18:53:23

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: Problem with Qt compilation

few example of qt apps in aur.... take a look boombox, bsc,kmp

you need to use lqt-mt

Offline

#6 2006-03-28 19:02:16

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

I looked in the Makefile and the LFLAGS is empty. How do I make qmake to generate Makefile correct?

Offline

#7 2006-03-28 20:07:16

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: Problem with Qt compilation

ok to build foo
in the dir foo source you should see foo.pro
qmake foo.pro
make
make install

this should work, if you are trying to learn the use kdevelop as that can automate a lot of tasks.
search the forums there is a link to a tutorial

Offline

#8 2006-03-28 20:48:38

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

Maybe my Qt isn't working, but I'm not stupid. As you can see in my first post I already tried "qmake -project && qmake && make" and make crashes - that's why I'ma asking how to make it work.

As for KDevelop, I'll think about that later, too bad I can't find an empty project option there. But from what I've already tested, qmake and make work from KDevelop :? Now I'm very confused...

Offline

#9 2006-03-28 21:03:41

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: Problem with Qt compilation

Benol wrote:

Maybe my Qt isn't working, but I'm not stupid. As you can see in my first post I already tried "qmake -project && qmake && make" and make crashes - that's why I'ma asking how to make it work.

As for KDevelop, I'll think about that later, too bad I can't find an empty project option there. But from what I've already tested, qmake and make work from KDevelop :? Now I'm very confused...

if qmake works there, the you need to check your code

Offline

#10 2006-03-28 21:08:12

emma
Member
Registered: 2006-02-19
Posts: 64

Re: Problem with Qt compilation

Benol: Upload your code somewhere and people can try to compile it. If it does not work for us, the problem is your code.

Offline

#11 2006-03-29 14:37:21

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

You have the errors in my first post, make doesn't seem to see Qt. But here you go - it's just the standart Qt tutorial.

[16:37] benol ~/qt $ cat test.cpp
#include <qapplication.h>
#include <qpushbutton.h>


int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    QPushButton hello( "Hello world!", 0 );
    hello.resize( 100, 30 );

    a.setMainWidget( &hello );
    hello.show();
    return a.exec();
}

[16:37] benol ~/qt $             

Offline

#12 2006-03-29 14:41:26

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: Problem with Qt compilation

no problem in compileing here:

[ronald@pressh_box test]$ gedit test.cpp
[ronald@pressh_box test]$ qmake -project
[ronald@pressh_box test]$ qmake
[ronald@pressh_box test]$ make
g++ -c -pipe -Wall -W -march=i686 -O2 -pipe  -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/opt/qt/mkspecs/linux-g++ -I. -I. -I/opt/qt/include -o test.o test.cpp
g++  -o test test.o    -L/opt/qt/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
[ronald@pressh_box test]$

Offline

#13 2006-03-29 15:22:54

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

It's the official tutorial, so there can't be any problems. The Qt installation is bad and I don't know what is happening hmm

Offline

#14 2006-03-29 15:25:08

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: Problem with Qt compilation

did you type it in manually or copy and paste as theat can introduce errors.

fifrefox is known for this

Offline

#15 2006-03-29 16:10:11

sh__
Member
Registered: 2005-07-19
Posts: 272

Re: Problem with Qt compilation

Weird.. it did not work out of the box for me (I'm using qt 3.3.6-2 from [extra]). The problem is that qmake does not generate a working Makefile. I could make the code compile with the following trick: run qmake -project && qmake, then edit Makefile and fix the LIBS = ... line:

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

After that run make and the errors are gone.

Offline

#16 2006-03-29 18:17:34

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

After editing the Makefile it worked. But why the hell does qmake generate unproper Makefile? :?

Offline

#17 2006-03-29 19:12:55

Benol
Member
From: Warsaw, Poland
Registered: 2006-03-20
Posts: 28

Re: Problem with Qt compilation

I think I'll stick with KDevelop, as it works fine and generates a good Makefile. But it's not the arch way not to know why simple `qmake` isn't working tongue

Offline

Board footer

Powered by FluxBB