Author Topic: Used to auto-build when adding new files, but not anymore?  (Read 5176 times)

Offline AntiElephant

  • Single posting newcomer
  • *
  • Posts: 6
Used to auto-build when adding new files, but not anymore?
« on: December 09, 2015, 01:57:27 am »
It used to be that if I swapped files in and out of my project and pressed F9 then it would update and auto-build with the new files completely.

However I updated to a new compiler (mingw-w64 GCC 5.2.0) and suddenly it won't auto build. If I take a file out of my project and add a new one in, press F9, then it always says in the build log:

"Target is up to date.
Nothing to be done (all items are up-to-date)."

And the program runs like I still have the old source files. There was no compiling done. I have to click "Rebuild" every time for it to register the change in files. I even tried uninstalling the new compiler and swapping back to codeblocks's default but I still have the error.

I must have clicked a setting accidentally which prevents the rebuilding when pressing F9.

What could the issue be?
« Last Edit: December 09, 2015, 01:59:06 am by AntiElephant »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #1 on: December 09, 2015, 05:28:26 am »
As far as I know this works fine.
Can you make a sample project and post the steps to reproduce the problem?
And what version are you using?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline AntiElephant

  • Single posting newcomer
  • *
  • Posts: 6
Re: Used to auto-build when adding new files, but not anymore?
« Reply #2 on: December 09, 2015, 12:53:18 pm »
As far as I know this works fine.
Can you make a sample project and post the steps to reproduce the problem?
And what version are you using?

I'm using 13.12 but it was working fine at one point.

http://imgur.com/a/KkPsq

There are a few screenshots.

In the first screenshot test.cpp is part of the project "Primer" and pressing F9 brings up the console with the desired output.

Then I remove test.cpp and add EX17.15.cpp to the project. This is a different source file with different output, but pressing F9 still brings up the console with output from the previous (i.e. test.cpp) source file. It hasn't compiled anything new, and it says at the bottom left that the target was up to date.

The only way to rectify this is to right click the project and say "rebuild", but I never had to do that before.

Third screenshot shows my compiler settings, but again it happens with even the default GCC compiler.

(Actually as I've discovered, if I were to change EX17.15.cpp in any way [e.g. by adding a comment] and then press F9, the project rebuilts as desired. It's only when I add it to the project without making any changes).

If you want to test this yourself. Start an empty project with a source file with a certain output and press F9 to build and run. Then remove that source file, add another one with a different output and press F9 to build and run. Does it rebuild the project?
« Last Edit: December 09, 2015, 02:38:24 pm by AntiElephant »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #3 on: December 09, 2015, 07:43:00 pm »
Ok, bug confirmed...
Not sure what we can do about it.

Morten any idea? Probably it happens because we're using only timestamps detect changes to the sources.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Used to auto-build when adding new files, but not anymore?
« Reply #4 on: December 09, 2015, 08:51:55 pm »
Morten any idea? Probably it happens because we're using only timestamps detect changes to the sources.
Well it looks like that but I wonder why it would have worked like that earlier then...

Actually we check the timestamp of the object file (which should be named differently in the example and therefore not present) to see if we need to build.

Did you play with the "flat objects" option or alike?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Used to auto-build when adding new files, but not anymore?
« Reply #5 on: December 09, 2015, 08:55:11 pm »
Hmmm... btw: It works for me on Windows. What I've done:

- Create a hello world console project
- compile & run (using F9)
- remove the "main.cpp" file from the project
- rename it on the disc to "main2.cpp" and changed some content (not using C::B)
- added "main2.cpp" to the project
- hit F9 and it compiles / links just fine.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Used to auto-build when adding new files, but not anymore?
« Reply #6 on: December 09, 2015, 08:55:36 pm »
Hmmm... btw: It works for me on Windows. What I've done:

- Create a hello world console project
- compile & run (using F9)
- remove the "main.cpp" file from the project
- rename it on the disc to "main2.cpp" and changed some content (not using C::B)
- added "main2.cpp" to the project
- hit F9 and it compiles / links just fine.

Is that what you did as well? Did I miss a step?

And btw: If I re-add "main.cpp" and remove "main2.cpp" it will not compile. But this is as expected because the related object file (main2.obj) is newer than the sourc file...

I assume you have an object file with the same name in place that is newer than the source file you add.
« Last Edit: December 09, 2015, 08:57:31 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #7 on: December 09, 2015, 09:06:41 pm »
You need to do the removing step twice.
1. build with main.cpp, remove it
2. build with main2.cpp, remove it
3. build with main.cpp -> builds nothing.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline AntiElephant

  • Single posting newcomer
  • *
  • Posts: 6
Re: Used to auto-build when adding new files, but not anymore?
« Reply #8 on: December 09, 2015, 11:19:39 pm »
You need to do the removing step twice.
1. build with main.cpp, remove it
2. build with main2.cpp, remove it
3. build with main.cpp -> builds nothing.

Yeah this is basically what happens. It should be building main.cpp on that third step, but it doesn't - so it gets left with the executable from building with main2.cpp.

I can't tell, but, are you able to obtain this bug too oBFus?


I even uninstalled CodeBlocks, removed the config data from %USER PROFILE%/AppData, deleted and created my project again, with no luck.

It was working one day, not the next. Not sure what's happened.
« Last Edit: December 09, 2015, 11:21:49 pm by AntiElephant »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #9 on: December 10, 2015, 12:48:37 am »
I can't tell, but, are you able to obtain this bug too oBFus?
Yep, I have reproduced the bug.

I even uninstalled CodeBlocks, removed the config data from %USER PROFILE%/AppData, deleted and created my project again, with no luck.
The file is not stored there. You have to either delete it from the .obj folder inside your project or just hit the rebuild project/workspace button.

It was working one day, not the next. Not sure what's happened.
I doubt it has been working. Probably you've been doing something else.

@Morten: Probably we can delete the object file for main.cpp when the main.cpp file is added to the project. This will make sure that the file gets recompiled and the project re-linked. What do you think? But for sure this should wait for the 15.12 release to happen.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Used to auto-build when adding new files, but not anymore?
« Reply #10 on: December 10, 2015, 08:39:31 am »
@Morten: Probably we can delete the object file for main.cpp when the main.cpp file is added to the project. This will make sure that the file gets recompiled and the project re-linked. What do you think? But for sure this should wait for the 15.12 release to happen.
I fully agree.

So the issue is that the executable is still newer than the object / source file on the second step. Therefore its not being build.

@AntiElephant: For now, please bind yourself a key / short-cut to re-build and use this instead. This won't harm for single file projects anyways and is just what you want.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #11 on: December 10, 2015, 09:04:02 am »
@AntiElephant: Also can you post an issue on in the tracker on sourceforge.net, so we have it in the list of bugs and so we won't forget about it?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline AntiElephant

  • Single posting newcomer
  • *
  • Posts: 6
Re: Used to auto-build when adding new files, but not anymore?
« Reply #12 on: December 10, 2015, 02:16:46 pm »
The file is not stored there. You have to either delete it from the .obj folder inside your project or just hit the rebuild project/workspace button.

I did all that too, but I was making sure I hadn't clicked a wrong setting somewhere in CB.

I doubt it has been working. Probably you've been doing something else.

I'm doing all the exercises in C++ Primer, and constantly swapping between source files as I complete new exercises and go back to my main testing source file (test.cpp). I must've swapped files near 1000 times, but I've pretty much never had to click "rebuild" until today. So I do find it very odd I did not come across this bug until recently.

I've added it to sourceforge:

https://sourceforge.net/p/codeblocks/tickets/270/

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Used to auto-build when adding new files, but not anymore?
« Reply #13 on: December 11, 2015, 12:17:58 am »
Thanks.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]