PDA

View Full Version : Undefined reference to my signal



tomek
6th January 2006, 00:52
Hi!
This is my first post so I'd like to say hello everyone!
I am trying to compile my simple project, but I get an error:

release\fetchThread.o(.text+0x387):fetchThread.cpp : undefined reference to `FetchThread::log(QString)'
release\fetchThread.o(.text+0x3ba):fetchThread.cpp : undefined reference to `FetchThread::connected()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\project.exe] Error 1
FetchThread::log(QString) and FetchThread::connected(void) are my own signals defined in the appropriate header file.
Files:
PROJECT DIRECTORY (http://cerber.cs.put.poznan.pl/~inf66293/ReSiStor/)
WRONG CPP (http://cerber.cs.put.poznan.pl/~inf66293/ReSiStor/fetchThread.cpp)
WRONG H (http://cerber.cs.put.poznan.pl/~inf66293/ReSiStor/fetchThread.h)
It complains about my signals emitted from the above CPP file.
Please help :)
Regards,
Tomek

jacek
6th January 2006, 01:14
It looks like make didn't run moc program on your fetchThread.h file. Run qmake (without any parameters) to generate new Makefiles and try compiling your project again.

wysota
6th January 2006, 01:19
Add HEADERS+=fetchThread.h to your .pro file.

tomek
6th January 2006, 01:25
Thank you! It works now.
First I added the HEADERS directive and then generated new Makefiles.
Happy New Year :)

katrina
6th January 2006, 02:29
I can't tell you how many times I have been banging my head on the desk asking myself "why isn't this compiling?!?" then realizing I need to run qmake again because I added another file to the project since last time I ran it.
(of course this is AFTER I go through all of the source code, like, 5 times lol)

Katrina

sunil.thaha
6th January 2006, 05:19
AFAIK. If you add a file then make calls qmake first. Only when u add Q_OBJECT to the class do we need to call the qmake manually.

shad
6th January 2006, 10:42
btw, there is a strange symbol (single quote) after "HEADERS" in the project file (http://cerber.cs.put.poznan.pl/~inf66293/ReSiStor/project.pro)

tomek
6th January 2006, 12:42
I found the apostrophe too, happily quickly :)
I've been always executing `qmake && make` not to forget about the qmake.
Thanks for your posts!

katrina
6th January 2006, 20:13
Only when u add Q_OBJECT to the class do we need to call the qmake manually.

This is good to know, I have been trying to run it after I add any new file regardless of of it Q_OBJECT-ed-ness. (although I tend to implement signals and slots heavily(maybe too much so!), so 80% of my new code is a Q_OBJECT...still good info!!! Thanks!)

Katrina

TheIndependentAquarius
1st December 2011, 08:14
Missing Q_OBJECT in the class declaration also does lead to the same error: undefined reference to `MyThread::MySignal()'