Make produces sometimes broken executables
-
Are you using qmake? If your dependency tree is right, it shouldn't happen.
I've saw cases when adding Q_OBJECT macro after the first compiling produces some mistakes related with moc and metaobject methods. But it will not affect the binary since your code will not compile.
Can you reproduce this problem and write down the steps here?
-
The problem occured again today. I am sure that the program does not mess up stack and there are no uninitilized variables anymore. The only thing that I changes was, that I placed a preprocessor directive around a debug logging statement, so it is only enabled when I compile the debug version.
After compilation, the program crashed repeatedly at the same point. I klicked on the rebuild link, which did not help. Then I inserted lots of additional debug messages to find the exact point because the debugger does not start properly (which is a well-known bug in the current release). But none of these new messages appeard, altough the program was obviously executing the related part of code.
So it was obvious that the make did not update the *.o file anymore. I selected the cleanup function in QT Creator, but some few files have been left in the build directory. After recompilation, the problem was still there. The I deleted the build directory manually, and voilla - problem was gone and the new debug messages are also visible now. The program does not crash anymore.
-
It is normal behaviour.
Whenever you make a change that requires the preprocessing of files, you need to rebuild at least that part of the source tree.
Always rebuild the complete source, or, split a big source tree up in managable parts.
Edit: to make this a little bit clearer:
Yes, the .cpp or .h file changed. It gets recompiled. However, it does not get preprocessed again automatically. -