About Shadow Build in Qt Creator
-
What does shadow build in Qt Creator signify?
Sometimes when a compilation error related to missing files occurs even when files are not missing,I uncheck shadow build, then my program seems to compile successfully.
[Moved to Tools ~kshegunov]
-
@Swati777999 said in About Shadow Build in Qt Creator:
What does shadow build in Qt Creator signify?
Not specific to creator. A "shadow build" is the preferred way in most configurations, that is when the build is put in a separate directory, which isn't part of the source tree.
Sometimes when a compilation error related to missing files occurs even when files are not missing,I uncheck shadow build, then my program seems to compile successfully.
Then probably you simply need(ed) to rerun
qmake
/cmake
. -
@Swati777999
The Qt tool chain, similar to others, has a bunch of code generating tools that are run during a compilation. Above all the Meta-Object Compiler (MOC). If you don't shadow build, all those files will clutter your source directory.And being the smart as tools that they are, they will not regenerate files, that already exist, if "nothing changed"
The problem now, is that detection is not 100 % reliable, especially if you switch between debug/release builds and/or compilers
Something similar happened in your described situation.The go to tool is a clean rebuild, aka rerunning qmake/cmake or simply deleting the shadow build folder.
don't uncheck the shadow build checkbox, you'll invite problems later down the line, if you have to change it select an other path/directory to shadow build in, it will have the same effect.
-
@J-Hilk said in About Shadow Build in Qt Creator:
@Swati777999
The Qt tool chain, similar to others, has a bunch of code generating tools that are run during a compilation. Above all the Meta-Object Compiler (MOC). If you don't shadow build, all those files will clutter your source directory.I am often helping people debug issues with mixing shadow / in-place builds. Building using a shadow /tmp is faster, so they decide to switch to that but then complain that changes to their forms / .ui files are not working. The uic is generating a new header file for their updated form but the c++ preprocessor finds the old one from the non-shadow build (i.e. without their changes). Unchecking shadow build will then result in builds updating the in-place files, so having the build 'work'. Like @J-Hilk said, make sure you have no Qt-generated files in your source directory when using shadow builds and don't switch between shadow / in-place without being very careful about old generated files.
Steve.