Author Topic: Does not recompile changed header files?  (Read 31242 times)

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: Does not recompile changed header files?
« Reply #15 on: June 20, 2012, 05:16:17 pm »
tested with release version 10.05
Adding -I. to compile successfully
and I reproduce the bug.

Watching the LogStream.depend:
strange: 3 entries for logstream.cpp (with different path)

Code
1340202085 c:\programacion\ktools2\headers\logstream.hpp
<string>
<fstream>
<stdexcept>
"..\..\Headers\General.hpp"
And I don't know how depend handle relative path
since
..\..\Headers\General.hpp should be relative to logstream.cpp directory
and not from LogStream.hpp directory (and it is LogStream.hpp which depends directly on General.hpp).
« Last Edit: June 20, 2012, 05:19:05 pm by jarod42 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Does not recompile changed header files?
« Reply #16 on: June 20, 2012, 05:31:52 pm »
10.05 is highly uninteresting version to test this :)
(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 carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #17 on: June 20, 2012, 08:31:57 pm »
Well, yes: some recent version would be better. But at least, that makes it less likely that the issue is just some bad configuration on my part  :)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: Does not recompile changed header files?
« Reply #18 on: June 20, 2012, 11:30:20 pm »
It works correctly here on windows (7600) and linux (8059).

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #19 on: June 20, 2012, 11:50:56 pm »
It works correctly here on windows (7600) and linux (8059).
Interesting, I have just tried the example on another computer (this one is windows, C::B 7966) and exactly the same happens. I can modify General.hpp as I want, even with illegal syntax, and it never recompiles.

But the fact that both you and I get consistent results on our different systems is interesting. Maybe it has something to do with the  C::B configuration we use??

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7678
    • My Best Post
Re: Does not recompile changed header files?
« Reply #20 on: June 21, 2012, 12:05:38 am »
@carra:

Do you try doing a full re-build before just changing something in the header file?
In other words these steps
1. Do a full re-build
2. Do a build and verify nothing is done.
3. Edit the header file
4. Do a build and see if it builds

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6036
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does not recompile changed header files?
« Reply #21 on: June 21, 2012, 03:37:32 am »
I download the KTool2.zip, and tested it.
First, I change
Code
"..\..\Headers\General.hpp"

Code
"General.hpp"

Then I build OK.

Next, I change any header file, then click build button.

I can't reproduce your issue, every thing works fine. (the cpp file will be re-compiled if a header file changes)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: Does not recompile changed header files?
« Reply #22 on: June 21, 2012, 06:14:03 am »
I download the KTool2.zip, and tested it.
First, I change
Code
"..\..\Headers\General.hpp"

Code
"General.hpp"

Then I build OK.

Next, I change any header file, then click build button.

I can't reproduce your issue, every thing works fine. (the cpp file will be re-compiled if a header file changes)
i had to change it touse "/" instead of "\" on linux, and added "." to the compiler search-directories as carra did.

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #23 on: June 21, 2012, 09:48:17 am »
Done this, results are down there on red
Do you try doing a full re-build before just changing something in the header file?
In other words these steps
1. Do a full re-build --> Done, everything rebuilds as usual
2. Do a build and verify nothing is done. --> Nothing to be done message
3. Edit the header file --> file modified
4. Do a build and see if it builds --> Again, nothing to be done message

Question: For those of you who cannot reproduce the bug, what is your *.depend file showing?? Because mine is this:

Code
# depslib dependency file v1.0
1340202051 source:c:\programacion\ktools2\sources\logstream\logstream.cpp
"..\..\Headers\LogStream.hpp"
<time.h>
<iostream>

1340202085 c:\programacion\ktools2\headers\logstream.hpp
<string>
<fstream>
<stdexcept>
"..\..\Headers\General.hpp"

As you can see, this is consistent with the problem (there is no entry for General.hpp)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6036
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does not recompile changed header files?
« Reply #24 on: June 21, 2012, 09:57:01 am »
It is mine
Code
# depslib dependency file v1.0
1340201559 source:c:\programacion\ktools\sources\logstream\logstream.cpp
<LogStream.hpp>
<time.h>
<iostream>

1339684374 source:c:\programacion\librerias\ktools\sources\logstream\logstream.cpp
<LogStream.hpp>
<time.h>
<iostream>

1340202051 source:c:\programacion\ktools2\sources\logstream\logstream.cpp
"..\..\Headers\LogStream.hpp"
<time.h>
<iostream>

1340202085 c:\programacion\ktools2\headers\logstream.hpp
<string>
<fstream>
<stdexcept>
"..\..\Headers\General.hpp"

1340202051 source:e:\code\cb\test_code\ktools2\sources\logstream\logstream.cpp
"..\..\Headers\LogStream.hpp"
<time.h>
<iostream>

1340242660 e:\code\cb\test_code\ktools2\headers\logstream.hpp
<string>
<fstream>
<stdexcept>
"General.hpp"

1340242644 e:\code\cb\test_code\ktools2\headers\general.hpp

Note: I have change your sample file a little to avoid a build error.
I download the KTool2.zip, and tested it.
First, I change
Code
"..\..\Headers\General.hpp"

Code
"General.hpp"

Then I build OK.

Next, I change any header file, then click build button.

I can't reproduce your issue, every thing works fine. (the cpp file will be re-compiled if a header file changes)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: Does not recompile changed header files?
« Reply #25 on: June 21, 2012, 10:26:39 am »
If I put '.' in search directory. It works as expected.
else if I add '-I.' as build option, I get the "Nothing to be done message".

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #26 on: June 21, 2012, 10:44:04 am »
As expected, you are not having the bug because your depend file has an entry for General.hpp. So why does my C::B not create the entry and yours does? Jarod's last comment is interesting, and it may shed some light on this. But maybe some people here have knowledge on how depend files are generated.

Also, some of you may be suspecting of the line
#include "..\..\General.hpp"
but I can confirm this is not the cause: The sample project I uploaded is just an "adapted copy", but the real project I'm writing (which has the same bug) uses absolute paths, and its include line is a more standard #include <General.hpp>

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Does not recompile changed header files?
« Reply #27 on: June 21, 2012, 10:58:58 am »
Do you have General.hpp in the filesystem or general.hpp?
Try matching the case.
On windows the case doesn't matter for files, but the dependency generator can be broken if the cases doesn't match.
(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 carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #28 on: June 21, 2012, 11:47:23 am »
Yes, cases do match in all file and folder names.

But I did find something new: I tried removing "General.hpp" from the project and my depend file changed to this:

Code
# depslib dependency file v1.0
1340201559 source:c:\programacion\ktools\sources\logstream\logstream.cpp
<LogStream.hpp>
<time.h>
<iostream>

1339684374 source:c:\programacion\librerias\ktools\sources\logstream\logstream.cpp
<LogStream.hpp>
<time.h>
<iostream>

This time, LogStream.hpp is the one missing!! And even if I readd to the project, it keeps missing, so now the 2 headers are missing from *.depend.

This makes me think that the bug we have is one (or both) of the following:

(1) C::B fails to update depend file when some relevant project changes happen
(2) C::B is somehow failing to include the first file in the project. The first file, before changing (as shown below), was General.hpp. After removing it, the first file is LogStream.hpp.

      <Unit filename="..\..\Headers\General.hpp" />
      <Unit filename="..\..\Headers\LogStream.hpp" />
      <Unit filename="LogStream.cpp" />

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Does not recompile changed header files?
« Reply #29 on: June 21, 2012, 02:34:12 pm »
Some more info: it seems that the missing entries in depend file are not the cause of the problem but an effect. I replaced the depend file with an earlier version (which had all files included) and C::B is ignoring it: no rebuild when changing any of the headers.

... and I don't think there is much more I can do. I tried most things I can think of... I think this will need an analysis of the source code.