Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. MacOS build fails when including moc files in cpp
Qt 6.11 is out! See what's new in the release blog

MacOS build fails when including moc files in cpp

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
7 Posts 2 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oxygen77
    wrote on last edited by
    #1

    I have a project that we build on several platforms including windows, linux, MacOS, ...

    I'm using qt5.15.2 on all plateforms. For macOS, I'm building on a mac mini M1 / macosx11.0 SDK.

    I've changed all .cpp files to include at the end the corresponding moc file when possible. No issue on linux 64 and windows 64 targets.

    But on MacOs the build fails:

    • I've fully removed the build folder,
    • Launched qmake + build from qtCreator

    => the error reported indicates that moc files are not present (missing file for the #include). I can see that moc_.cpp files are listed at the end of OBJECTS section of Makefile

    I've tryed to force moc creation by adding a custom make call in qtCreator with target mocables. This did the trick for generating the moc and including them in .cpp but moc_*.cpp are still build creating duplicate symbols.

    Is including moc in .cpp not compatible with some part of my build chain for mac ? It looks like qmake is not detecting that the files are already included and can be discarded from OBJECTS

    Of course I can add some #ifdef to make the #include valid only on selected plateforms but I have a lot of files to change and I would prefer to keep the same logic everywhere

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you trigger that with a minimal example ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • O Offline
        O Offline
        oxygen77
        wrote on last edited by
        #3

        Thx for the advice, I've loaded notepad exemple for qt tutorial and simply added the #include at the end of notepad.cpp

        Build is fine, which is a good start.

        I've added all specific addition from our .pro to the notepad.pro and could not make the build to fail (removing build folder each time).

        In our source tree of course there is a lot more files needing a moc. We also have some interface class that don't have code associated, these .h files were treated well on other platform as a moc_XXX.cpp is generated and build. I don't get at this point on macos

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So the header only files are wreaking havoc ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • O Offline
            O Offline
            oxygen77
            wrote on last edited by
            #5

            @SGaist said in MacOS build fails when including moc files in cpp:

            wreaking havoc

            Sorry I was trying to find differences, but don't have a clear view on what is going on with my project build.

            I just run a script to remove all these includes and build is back ok. I will try to add just on one file for a start.

            Any idea why qmake is not producing the right Makefile ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you re-run qmake after modifying your cpp files ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • O Offline
                O Offline
                oxygen77
                wrote on last edited by
                #7

                Hello, so removing include solved the problem of course. I’ll start from this and add one or two include to test and understand.

                And yes I’m running qmake and even better, I remove the full build folder.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved