Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mdzahidh on December 29, 2009, 01:08:27 pm

Title: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 01:08:27 pm
I ported the PBRT (Physically Based Rendering Toolkit) source code into Codeblocks project (not using the custom makefile provided by the PBRT). The the trouble is, the header dependency is not working properly. For example if a cpp file A.cpp includes A_header.h and if i modify A_header.h, and do a build, the A.cpp is not recompiled and the the build system does nothing ! However, if i right click on the line of A.cpp
where it says "include A_header.h" and say "Open header" it opens A_header.h properly. So obviously the system can locate the header file but for some reason, the dependecy of A.cpp on A_header.h is not workign properly at build time.
Title: Re: Header dependency in the build
Post by: zabzonk on December 29, 2009, 01:12:23 pm
Are you sure the modification times on the sources are consistent with the system time on your own box?
Title: Re: Header dependency in the build
Post by: ollydbg on December 29, 2009, 01:16:03 pm
works fine here, which version of CB did you use?
Title: Re: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 10:18:03 pm
yes, i checked the modification time and it is consistent with the system time. I modified the file from within CB and checked the modification time using "stat" Even if a header file is modified the corresponding source wouldn't be recompiled when I do a build !

I am using CB 8.02. Any idea why isn't this working ? :(
Title: Re: Header dependency in the build
Post by: stahta01 on December 29, 2009, 10:42:05 pm
Simple Questions that I have no idea if the apply to Code::Blocks IDE.

1. Are you using include "file.h" or <file.h>?
I would guess include "file.h" is correct.

2. Does the header file belong to the project?
I would add the header to the project.

Tim S.
Title: Re: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 10:52:20 pm
Yes, both conditions are satisfied ! The situation is, the source tree has several directories.. so for example it has a directory called "volumes", see below

src
 |
 |----> volumes
              |
              |exponential.h
              |exponential.cpp

So both exponential.h and exponential.cpp are in the same folder "volumes." In the file "exponential.cpp" its written

#include "volumes/exponential.h"  // since the build is performed from the root directory "src"

but if i change/modify exponential.h then and then do a "build", it says "Nothing to be done" :(

Title: Re: Header dependency in the build
Post by: zabzonk on December 29, 2009, 10:54:49 pm
Quote
yes, i checked the modification time and it is consistent with the system time. I modified the file from within CB and checked the modification time using "stat"

But are the times for the .cpp files that depend on the header consistent? In other words, are their times prior to that on the modified header?
Title: Re: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 10:55:43 pm
Arright, i think i found a pattern here.

if in a .cpp file the headers are included without directory prefix for example

#include "someheader.h"

then modifying that header also triggers a recompilation of the source file :)

but if its written

#include "dir/someheader.h"

it fails to recognize the modifications in the header file :(
Title: Re: Header dependency in the build
Post by: zabzonk on December 29, 2009, 11:41:44 pm
As stahta01 asked - are you adding these header files to the project? The mere fact that a header exists somewhere on the system, even if it is on the include path does, not guarantee the dependency mechanism will do what you want.
Title: Re: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 11:44:10 pm
yes, the headers are added in the project as well ! but i dont know if it is CB feature or not, the header files (in the project browser) is colored gray. Does that imply anything ?
Title: Re: Header dependency in the build
Post by: zabzonk on December 29, 2009, 11:53:01 pm
Quote
Does that imply anything?

I have no idea :-)  But that's how they appear in my projects, and I have no dependency problems.
Title: Re: Header dependency in the build
Post by: mdzahidh on December 29, 2009, 11:58:02 pm
but im kinda convinced that it has something to do with the directory prefix in header , the one that i talked about earlier. And I noticed that this pattern is consistent throughout the project, where ever i have directory prefix in my while including the header, the header dependency gets screwed. Could be a bug in CB ?