Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Why don't you create a new moc using the new Version (in your case it is 4.7.3) and the corresponding header file.

   moc ****.h -o ***.moc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top