LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-11-2004, 04:11 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
QT tutorial


I am trying to learn qt. But now when coming to compiling several files it seems to be something wrong.

I have three files in a directory called t7.
To make sure I haven't typed anything wrong I have copied and paste the text from the three files in the tutorial. The files are:
lcdrange.h
lcdrange.cpp
main.cpp

Now here is the error:
Code:
mezzymeat@garanka:/User/programming/qt/t7$ g++ -I/usr/local/qt/include/ -L/usr/local/qt/lib/ -lqt lcdrange.cpp main.cpp
/tmp/ccm135p8.o(.text+0x1f): In function `LCDRange::LCDRange[not-in-charge](QWidget*, char const*)':
: undefined reference to `vtable for LCDRange'
/tmp/ccm135p8.o(.text+0x2b): In function `LCDRange::LCDRange[not-in-charge](QWidget*, char const*)':
: undefined reference to `vtable for LCDRange'
/tmp/ccm135p8.o(.text+0x1b9): In function `LCDRange::LCDRange[in-charge](QWidget*, char const*)':
: undefined reference to `vtable for LCDRange'
/tmp/ccm135p8.o(.text+0x1c5): In function `LCDRange::LCDRange[in-charge](QWidget*, char const*)':
: undefined reference to `vtable for LCDRange'
collect2: ld returned 1 exit status
 
Old 11-11-2004, 05:05 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
This code uses signals and slots, which Qt implements swith the MetaObject Compiler (moc).

You need to run this source code through moc, to generate the metaobject files *_moc.cpp, and compile these files as well.
 
Old 11-11-2004, 05:57 AM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Quote:
Originally posted by rjlee
This code uses signals and slots, which Qt implements swith the MetaObject Compiler (moc).

You need to run this source code through moc, to generate the metaobject files *_moc.cpp, and compile these files as well.
How do I run source through moc to create these files?

EDIT:

I checked out man moc and it was right. :P
But I could not generate moc-files correctly, they become empty.
Code:
mezzymeat@garanka:/User/programming/qt/t7$ moc -o lcdrange.moc lcdrange.cpp 
lcdrange.cpp:0: Warning: No relevant classes found. No output generated.
mezzymeat@garanka:/User/programming/qt/t7$ moc -o main.moc main.cpp         
main.cpp:0: Warning: No relevant classes found. No output generated.
Also even tried to do the same with the headerfile but same result there. The files are still exactly the same as the examples.

Last edited by Ephracis; 11-11-2004 at 06:05 AM.
 
Old 11-11-2004, 12:21 PM   #4
phoenix7
Member
 
Registered: Aug 2004
Distribution: Mandrake 10.2(Mandriva), SuSE 9.3, Slackware 9.1, Xandros 3.1, Knoppix 3.9, FreeBSD 5.3, RedHat9
Posts: 122

Rep: Reputation: 15
I think your problem is about making (linking).
you shouldn't need to change your code.
 
Old 11-11-2004, 12:22 PM   #5
phoenix7
Member
 
Registered: Aug 2004
Distribution: Mandrake 10.2(Mandriva), SuSE 9.3, Slackware 9.1, Xandros 3.1, Knoppix 3.9, FreeBSD 5.3, RedHat9
Posts: 122

Rep: Reputation: 15
do you know qmake?

you can try these :
Code:
qmake -project
Code:
qmake
Code:
make
I wish this solve your problem?
 
Old 11-11-2004, 12:44 PM   #6
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Yeah I know about qmake but I like to compile by myself, I feel that I learn more then. But I did qmake and saw which commands that were used.

If anyone else would have this problem here is how to compile it:

First create object-files of all the source-files (not the headers).
Then run moc on the headerfile.
After that do the same with the new moc-file (create an object-file).
At last link the object-files together and create the binary.

I rather understand this then just knowing how to spell to "qmake -project". :P
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
QT tutorial vinsky2002 Linux - Software 2 03-02-2005 03:15 AM
looking for a tutorial!!! mio_carpe Linux - Networking 2 01-29-2005 02:29 PM
Need help w/tutorial FreakboY Programming 10 05-10-2004 05:30 PM
Tutorial Marklar Linux - Networking 11 12-20-2003 07:44 PM
How about a weekly tutorial? or just a tutorial Alinuxnoob LQ Suggestions & Feedback 2 04-09-2002 08:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration