I have a project for which I regularly modify headers and when I do so, and forget to make clean
then make
, I get all sorts of weird behavior. I'm currently using Qt Creator as my IDE, but I've seen this happen on a Qt-independent project. My project is getting fairly large, and having to rebuild every time I make a header change is becoming unproductive. Any thoughts?
For future reference:
If using the QMake system:
DEPENDPATH += . \ HeaderLocation1/ \ HeaderLocation2/ \ HeaderLocation2/HeaderSubLocation1/ \ HeaderLocation2/HeaderSubLocation2/ \ HeaderLocation2/HeaderSubLocation3/ \ HeaderLocation2/HeaderSubLocation4/ \ HeaderLocation2/HeaderSubLocation5/ \ HeaderLocation3/ \ HeaderLocation3/HeaderSubLocation1/ \ HeaderLocation3/HeaderSubLocation2/ \
Re-run qmake
. This will generate a new Makefile which will have proper dependencies.
Example:
A file file.h
looking like the following:
#include "some.h"
#include "header.h"
#include "files.h"
...
and file.cpp
looking like the following:
#include "file.h"
...
and having in your .pro
:
HEADERS += file.h some.h header.h files.h
SOURCES += file.cpp
will produce the following in the resulting Makefile
:
file.o: ../src/file.cpp ../src/file.h \
../src/some.h \
../src/header.h \
../src/files.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o file.o ../src/file.cpp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With