Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-58857

Fatal error creating moc_predefs.h

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.9.0 Beta 2
    • 5.8.0
    • Build System
    • None
    • Qt5.8
      Linux 64bit
    • 6282948e96659bbf718ec1df29a8f7bb2a5db464

    Description

      I have a project that uses a library containing some protobuf classes that I need to import. The library contains all the correct export symbols and macros but wont compile if my project hasnt got the appropriate header to resolve the export macro. Seems how 'proto' creates its own pb.h and pb.cc files it is incredibly difficult to inject the include statement into the proto auto-generated code. Editing these 'proto' generated files by hand is not an option. Adding another external code manipulation step to run after 'proto' is undesirable.
      The simplest solution I have found to get the library to import and compile in QtCreator is to provide the global import header as a QMAKE_CXXFLAGS compiler option in the .pro file, like this:

      QMAKE_CXXFLAGS += "-include header_global.h"
      

      Which used to solve the issue. Now in Qt 5.8 I get the following error and message during build:

      /opt/Qt/5.8/gcc_64/bin/qmake -o Makefile ../../MyProject.pro -spec linux-g++ CONFIG+=qtquickcompiler
      g++ -pipe -include header_global.h -O2 -std=gnu++1y -Wall -W -dM -E -o moc_predefs.h /opt/Qt/5.8/gcc_64/mkspecs/features/data/dummy.cpp
      cc1plus: fatal error: header_global.h: No such file or directory
      compilation terminated.
      Makefile:807: recipe for target 'moc_predefs.h' failed
      

      If I modify it as follows:

      QMAKE_CXXFLAGS += "-include $PWD/../MyProjectB/header_global.h"
      

      It finds the header fine but moc then complains as follows:

      In file included from <command-line>:0:0:
      xxxx/../MyProjectB/header_global.h:4:28: fatal error: QtCore/qglobal.h: No such file or directory
       #include <QtCore/qglobal.h>
                                  ^
      compilation terminated.
      

      moc appears to have stopped respecting the project INCLUDES.

      If I remove the QMAKE_CXXFLAGS statement completely, I just go back to having compile errors because it wont understand the library export macro.

      This error is new in 5.8. It has previously compiled fine in 5.6 and 5.7.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            wmh William Horner
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes