PDA

View Full Version : Problem with Q_Object and XCode



bjoernbg
27th February 2008, 08:54
Hello everyone,

I've been using Qt 4.3 successfully with XCode for a while. Now I had to use signals and slots and to implement these I have to use the Q_Object macro. However, as soon as I include the macro, XCode won't build my project any more. It reports an error during Linking that reads like this:


x 'vtable for MyDialog', referenced from:
__ZTV8MyDialog$non_lazy_ptr in MyDialog.o
symbol(s) not found
collect2: Id returned 1 exit status
Build failed (1 error)

I don't know why I get this error. It probably is something stupid, as the exact same project compiles and runs perfectly on Windows XP with Eclipse.

Please, can anyone turn me in the right direction?
I had this problem before and was not able to solve it. The Qt-Demo-Projects using Q_Object compile and run fine...

Any help?

wysota
27th February 2008, 09:03
You need to rerun qmake when you add the Q_OBJECT macro to a file.

bjoernbg
27th February 2008, 09:35
Thanks, that did something and added the moc-file to the project. However, I get now several other Linker errors - see Attachment.

Also, can't I rerun qmake and NOT loose my existing XCode-Project settings? I've customized several targets etc., automatically including the Qt Framework etc. It's quite a bit of work to recreate all that each time I have to run qmake for something like this...

I was finally able to get the project to work, but only by deleting most of the contents in my projects folder, including the project file, generating a new project file and then running qmake. But please - there GOT to be a better way to do this!

wysota
27th February 2008, 09:54
Thanks, that did something and added the moc-file to the project. However, I get now several other Linker errors - see Attachment.
Check if you have those methods implemented.


Also, can't I rerun qmake and NOT loose my existing XCode-Project settings?
No idea. As far as I know qmake can generate an xcode project file for you, but in general an existing project (generated by qmake) should be able to handle files containing Q_OBJECT. Otherwise you have to implement some rule for xcode yourself that runs moc on appropriate files.

THRESHE
27th February 2008, 15:38
When I add new files to my project on a Mac I just delete old xcode project and generate new one. Usually this helps :)