MacOS build fails when including moc files in cpp
-
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
-
Hi,
Can you trigger that with a minimal example ?
-
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
-
So the header only files are wreaking havoc ?
-
@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 ?
-
Did you re-run qmake after modifying your cpp files ?