6

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?

3
  • 1
    have you tried doing a "make clean" to remove previously generated files, and re-running "make" after that?
    – Mat
    Commented May 18, 2011 at 9:41
  • 4
    Are you sure you're not still somehow using the includes from an older version of Qt?
    – Bart
    Commented May 18, 2011 at 9:43
  • 1
    Try with a clean checkout/remove all moc_/.moc files, rerun qmake 4.7.3 and make. Commented May 18, 2011 at 9:52

3 Answers 3

8

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.

1
  • what's the equivalent of make clean in cmake?
    – Owen
    Commented May 19, 2011 at 5:35
2

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.

0
0

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
1
  • In the error message it seems to state that it has been created with the current MOC tool, but that the headers used are too old.
    – Bart
    Commented May 18, 2011 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.