Question: Sometimes when I change code in my Qt project (Qt Creator 2.1.0 with mingw32), the changes don't get reflected in the produced machine code after building it. This happens mostly when I change things like default values in constructors or the order of parameters in methods/constructors. Usually, a full rebuild fixes that (but takes a few minutes).

I'm helping myself by deleting the generated executables or librarys before building, which seems to help most of the time. Does that mean that theres something going wrong when linking the object files?

I'm coming from java/.net and I'm used to a different behaviour. I'd be happy if anyone could explain me what I'm doing wrong and/or point me to some related articles.

Thank you!

Answer: 
The most common case for that are broken dependencies. In the particular case of default arguments to functions, they are resolved at the place of call, so if you just recompile the function, the code will be exactly the same. You need to recompile the *caller*. If the dependencies in the project are not correct and the build system does not detect that it needs to recompile the caller, and only recompiles the callee then you will see that effect.

Analyze the dependencies and fix them.

Example:

```
// what you write                  // what the compiler generates
void foo( int i = 0 ) {}           void foo( int i ) {} // default removed
int main() {                       int main() {
   foo();                             foo( 0 );         // compiler injected
}                                  }

```
If your `Makefile` (or your moral equivalent to a `Makefile`) is missing dependency information, then you can get out-of-sync builds. For every file with `#include "header.h"`, you need to make sure the `Makefile` puts `header.h` as a dependency on that file.

Here is a small piece of a `Makefile` I've got:

```
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h
        $(YACC) $(YFLAGS) -o parser_yacc.c parser_yacc.y

parser_lex.c: parser_lex.l parser_yacc.h parser.h
        $(LEX) ${LEXFLAGS} -o$@ $<

parser_lex.o: parser_lex.c parser.h parser_yacc.h
        $(CC) $(EXTRA_CFLAGS) -c -o $@ $<

parser_misc.o: parser_misc.c parser.h parser_yacc.h af_names.h cap_names.h
        $(CC) $(EXTRA_CFLAGS) -c -o $@ $<

```

Each object file clearly depends upon the corresponding source and header files. If we forgot `cap_names.h`, then `parser_misc.o` wouldn't be rebuilt when `cap_names.h` is modified. Bugs can ensue.

I'm afraid the fix is long and tedious: inspect every file, make a list of its dependencies, and add missing dependencies to the `Makefile`. On a Linux platform, you could use the `strace(1)` tool to discover which files the compiler needs to open when compiling each source file, and improve the dependencies with that list. I do not know if any similar tool exists on Windows, but it would be worth spending a few minutes looking for one before diving in.