Search code examples
c++qtcompilationqt-creatorbuild-process

Code changes do not take effect


I just started using Qt Creator 3.5.0, Qt 5.4.2 with GCC on Kubuntu 15.10. I created a new project, added a window and currently I am trying to develop a new module.

However strange things happen.

I wrote a debug output line in my template class X. The line is located in a function of class X in the header of its module, e.g.:

qDebug() << "Hello1" << endl;

After building and running the application this line is executed and "Hello1" is printed in the debug console as desired. Also I can use the debugger and step through the line. When building the application the compiler does essentially nothing since no code file was changed (as expected).

When editing the above line things go weired:

  • I changed the line to "Hello2" and saved the code file.
  • I could see the correctly updated file modification date/time of the source file and I verified that the file is newer than the corresponding object file.
  • When buildung the project the compiler actually compiled the edited source file and linked the application as expected. I verified the updated object file date/time and the update executeable file date/time.
  • However when starting the application the behavior did NOT change! The output is still "Hello1".
  • When searching through the executeable using a binary editor I can still see the old string "Hello1" only. No other string containing "Hello".
  • After doing the above again (changing the line to "Hello3") still "Hello1" is printed.

More facts:

  • When re-building the entire application or after cleaning the project the change takes effect a single time.
  • The problem is reproducible every time on every edit.
  • I couldn't observe this with any other module, it happens with that one source module only that seems not to be different in a significant way.
  • As mentioned the code line is located in the module header. But modifing the module itself doesn't change anything.
  • Changing class X and a second module at the same time does not change anything (modification in the second module takes effect, modification in class X doesn't have an effect).
  • Both header and module were correctly added to the .pro file.
  • Restarting QtCreator does not change anything.
  • This happens with and without debugger.
  • Makefile rules for the class X module look sensible and are not different than the rules of other modules.

I have no idea how this is possible. Maybe I missed something obvious. Any ideas?

UPDATE: Using system monitor I could confirm that the running process uses the expected executeable.


Solution

  • You can try some things:

    1. Check if the exe your are opening its on the same path as the created one (you can verify it looking into .pro.user file.
    2. Check if when you compile, it does save the changes first and then compile it together otherwise it may seem it does it but don't.
    3. If you have changed your .pro file run qmake and build it again.
    4. Try cleaning, runing qmake and re-building the project.
    5. If you changed your .pro file or you are including external libs or files, check the output log to see if everything is ok, sometimes it is not but stills compiles (and then doesn't link well or just let you the old compiled version).

    It seems to be compiling the last 'version' of your code and not applying the changes for some of that reasons and others (If I think in other things I'll edit the post later).

    Hope it helps