Jump to content

Hello world with Qt [solved]


Recommended Posts

This is probably going to make me look really dumb that I can't figure this out, but hopefully you'll all go easy on me! I can't get the hello world demo for Qt to compile :unsure:

I'm trying to make it as simple for myself as poss, I took the source from

http://doc.trolltech.com/3.3/tutorial1-01.html

and followed their (simple!) instructions: qmake -project and then qmake and then make, but I just get error messages and no executable.

From qmake -project I get a .pro file, and qmake then generates a Makefile. Then make just spits out a screenful of "undefined reference" messages, for example:

g++  -o qt hello.o    -L/usr/X11R6/lib -lXext -lX11 -lm
hello.o(.text+0x33): In function `main':
: undefined reference to `QApplication::QApplication(int&, char**)'
hello.o(.text+0x44): In function `main':
: undefined reference to `QString::QString(char const*)'
hello.o(.text+0x62): In function `main':
: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*, char const*)'

and then at the end

collect2: ld returned 1 exit status
make: *** [qt] Error 1

As far as rpms go I have libqt3-3.3.4-7.1.102mdk, aqhbci-qt-tools-1.0.3-0.beta.1mdk, qt3-common-3.3.4-7.1.102mdk and libqt3-devel-3.3.4-7.1.102mdk, and in the file system I've got lots of files under /usr/lib/qt3. It doesn't seem to be complaining about missing files though, so I think it can find the qt stuff.

I can't work out if this is a qt3 thing or just a Makefile / C++ misconfig. Can anyone help please?

Link to comment
Share on other sites

I'm definitely no expert, but as a wil stab in the dark, you don't seem to be linking against any QT libraries in your compile command. Possibly where the undefined errors are coming from? Then again, the errors sound more like you haven't included the header files for those functions :s. Use python :D

Link to comment
Share on other sites

Well, as I said I've got libqt3-devel-3.3.4-7.1.102mdk so that should be the development package, right? And the qmake should have sorted out my dependencies, I guess. I tried just doing a g++ (without 'make') with a -I to include my qt libs, and just got the same errors. Hmmm.

 

In the meantime, someone suggested it would all be easier with kdevelop, has anyone experience with that? It's 200MB + though, yikes! Or has anyone done any Qt stuff with eclipse? I already have eclipse for java, it's pretty cool, but I don't know how to get it going with C++/Qt - any tips?

Link to comment
Share on other sites

Fixed! :D

You'll never believe what the problem was - I had created a separate directory in which to do this experimenting, so what did I call the directory? Well, "qt", of course, cos I'm playing with qt. Except that "qt" means something special when it's doing its compilation stuff, so it falls over. Clever, huh? :wall:

 

Renamed the directory to something else, did the compilation, and it worked smooth as a wotsname. I am now cooking with hi-octane gas :banana:

 

PS/ I'm not even pretending to have found the answer on my own, I never would have without the help of the qt forum. But I'll post the answer here in case anyone else is playing with this stuff.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...