PDA

View Full Version : Why don't Qt Creator projects recompile after header changes?



tksharpless
15th May 2011, 02:12
With the last 2 incarnations of Qt for Windows I've used, 4.6 and SDK 1.1, I've noticed that editing a header file does not trigger recompilation of unchanged sources that include it. This is true with both the Gnu and MSVC tool chains in SDK 1.1. It leads to various errors, not all of which are caught by the linker. So I have to 'rebuild all' quite often to get a working program. I am not using precompiled headers.

I wonder if this is a true bug, or if it can be fixed by some configuration setting I am not aware of?

-- Tom

ChrisW67
15th May 2011, 09:47
Qmake generates makefiles that include header files as dependencies (direct or indirect inclusion) of the object (.o) file for me (Qt 4.7.2 on Linux and 4.6.2/4.7.0 in the 2010.02/2010.05 SDK for Windows). Consequently, touching one of the headers will recompile the source to get the object.

Can you provide a small example that does not work for you?

wysota
15th May 2011, 09:51
It is important that you add your header files to the HEADERS variable in the project description.

tksharpless
16th May 2011, 16:21
I only have a quite large example now. All of my header files are named in the project file's HEADERS variable.

Just to provoke thought, here is a piece of a Makefile for my big project:


debug\test-v1_main.obj: ..\panini-test\test-v1_main.cpp ..\panini-test\test-v1_window.h \
..\panini-test\test-v1_view.h

debug\test-v1_window.obj: ..\panini-test\test-v1_window.cpp ..\panini-test\test-v1_window.h \
..\panini-test\test-v1_view.h

debug\test-v1_view.obj: ..\panini-test\test-v1_view.cpp ..\panini-test\test-v1_view.h

debug\HermiteSpline.obj: ..\..\Panini-Core\src\HermiteSpline.c

debug\splinemap.obj: ..\..\Panini-Core\src\splinemap.cpp

debug\slidewindow.obj: ..\..\Panini-Core\src\slidewindow.cpp

debug\paninilens.obj: ..\..\Panini-Core\src\paninilens.cpp

debug\lensdbdialog.obj: ..\..\Panini-Core\src\lensdbdialog.cpp ui_lensdbdialog.h

debug\CameraDBDialog.obj: ..\..\Panini-Core\src\CameraDBDialog.cpp ui_CameraDBDialog.h

debug\slidearray.obj: ..\..\Panini-Core\src\slidearray.cpp

debug\vnslide.obj: ..\..\Panini-Core\src\vnslide.cpp


All of these sources have corresponding .h files, however only a few of those are explicitly given as dependencies in the makefile. Whether there is a moc file is not decisive; for example test_v1_window has a moc, as do most of the other sources whose headers are not mentioned; but test_v1_main, HermiteSpline and splinemap do not have mocs.

Apparently the problem is that (in most cases) neither the dependency on the original header, nor on the moc file, is given. That would seem to be a QMake bug (or could it be a feature?).

-- Tom

wysota
16th May 2011, 22:09
As far as I know they don't have to be given explicitly in the Makefile as gcc is used to detect dependencies during compilation. I have no problems with dependencies in my projects and some of them are quite large and complicated.

dbradley
19th October 2011, 18:20
I've encountered the same issue. Building on Windows using Qt 4.7. I've added a few simple classes to my project and if I modified a header file, the cpp files using them do not get compiled. Headers are listed under the Headers folders and were created by Qt when I created the class. And my compiler is Visual Studio 2005.