Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's causing this QT 4.7.3 error?

I have a program which compiles just fine in OpenSuse 11.2 with QT version 4.5. However, when I compiled the same program using OpenSuse 11.4 with QT 4.7.3, I'm getting this error message:

"This file was generated using the moc from 4.7.3. It cannot be used with the include    files from this version of Qt. The moc has changed too much"

Can anybody tell me what's going on?

like image 793
Owen Avatar asked May 18 '11 09:05

Owen


2 Answers

This error occurs because you are using a project that was compiled on one version of Qt. The main reason for this is that Qt uses moc tool that creates glue code for signal slot handling and other stuff.

Moc does this by parsing the header files to find definitions like Q_OBJECT, signal:, slot:, etc.

This code is completely tied to the Qt version that was used for creating this code. In some cases, this code is completely incompatible even for same version of Qt library which was configured with a different set of options.

This case is true even for some changes in .pro, e.g, using CONFIG += no_keywords causes moc to generate different glue code allowing Qt to work with other libraries such as boost which provide signal slot mechanisms using same keywords like Qt.

So, in short, whenever you need to compile Qt project against a different Qt library, make sure you do the following: 1. run: make distclean 2. run: qmake 3. run: make

this will always give you a clean build tree.

like image 189
Muhammad Anjum Kaiser Avatar answered Sep 20 '22 13:09

Muhammad Anjum Kaiser


In my case, it was because I was running "qmake" instead of "qmake-qt4". "qmake" is apparently Qt3. I encountered this on Fedora Core 16.

Why it's not "qmake-qt3" and "qmake" respectively, is beyond me.

like image 42
ulatekh Avatar answered Sep 23 '22 13:09

ulatekh