ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.