Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make doesn't rebuild headers when changed

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/ \
like image 274
Drise Avatar asked May 17 '12 14:05

Drise


1 Answers

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
like image 56
leemes Avatar answered Oct 14 '22 09:10

leemes