Author Topic: What's up with .depend files?  (Read 20489 times)

Offline tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
What's up with .depend files?
« on: September 18, 2011, 10:22:41 pm »
First of all many thanks for developers who created such a great product and then gave it out for free. I started using CB about a month ago and except for this particular issue found it quite useful.

Here is my problem - .depend files for all my projects contain only the following line:

# depslib dependency file v1.0

Because of that if a header file is changed I have to rebuild the whole workspace to guarantee to get the changes.

I did many builds/rebuilds for both Debug and Release mode using the global workspace or individual projects. I noticed that sometimes a project .depend would contain correct dependencies information, but then it would be gone after next edit/build. I couldn't observe any logic in how/when dependencies are generated (or rather not).

Editing .cpp files works fine - relevant libraries are built and dependent programs relinked.

I searched Internet and these forums for the topic and found a couple similar complains without any resolution.

BTW I have a parallel set of regular Makefiles that utilize recommended generation/usage of .d files - and this setup works correctly for the same source code.

My system:

30 C++ projects organized into one global workspace
CodeBlocks 10.05
Scientific Linux 6.1 x86_64

Any help would be greatly appreciated.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: What's up with .depend files?
« Reply #1 on: September 18, 2011, 10:37:43 pm »
Is this what you are looking for?

You could also try Project->Properties...->Build targets (tab)->Dependencies... and add all the used header files as External dependency files (this would have to be done on all relevant projects).

Offline tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #2 on: September 19, 2011, 03:12:34 am »
I am not looking for how to set up inter-project dependencies. I did it and it works great. What I am looking for is how/when .depend files are generated. These files contain dependencies at the source code level, e.g. which .cpp files depend on which .h files. For some reason in my case all .depend files are empty, so when a header file is modified .cpp files that depend on it are not re-compiled.

Probably generation of .depend files happens at the Preprocessing phase (from the link you provided). Unfortunately there are no more details about what exactly going on at this phase.

Any other ideas/pointers?

Offline tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #3 on: September 19, 2011, 03:19:34 am »
More details about my setup:

In Toolchain executables I set to use ccache to speed up compilation:

C compiler: ccache_gcc
C++ compiler: ccache_g++

where ccache_gcc is the following script:

Code
#!/bin/sh

## Invoke g++ with ccache and pass all parameters to them
ccache gcc "$@"

and

ccache_g++:

Code
#!/bin/sh

## Invoke g++ with ccache and pass all parameters to them
ccache g++ "$@"



Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: What's up with .depend files?
« Reply #4 on: September 19, 2011, 04:57:00 am »
What I am looking for is how/when .depend files are generated. These files contain dependencies at the source code level, e.g. which .cpp files depend on which .h files. For some reason in my case all .depend files are empty, so when a header file is modified .cpp files that depend on it are not re-compiled.
OK, that makes sense; unfortunately I do not have much experience with .depend files.
Have you tried
You could also try Project->Properties...->Build targets (tab)->Dependencies...
Sometimes I find that simply opening the External dependency window causes Code::Blocks to correctly generate .depend files.

(Your compiler setup looks fine so I doubt that is the problem.)

@Anyone else: Perhaps someone with more experience in this area could share their thoughts?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: What's up with .depend files?
« Reply #5 on: September 19, 2011, 09:10:55 am »
tankist02: can you try with the normal g++, without ccache?
(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 tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #6 on: September 19, 2011, 09:31:18 pm »
Did that. Rebuilt a few times, closed and opened CB, even opened External dependencies dialog - didn't help. BTW rebuild time went from 1 min (with ccache) to 7 mins (without ccache). I'd rather keep using ccache. :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: What's up with .depend files?
« Reply #7 on: September 19, 2011, 09:39:17 pm »
A shoot in the dark; are the includes
Code
#include "header.h"

or
Code
#include <header.h>

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 tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #8 on: September 20, 2011, 12:02:23 am »
I have both: <> for system files and "" for my own code. I am interested in dependencies of .cpp on my headers.

What's interesting: I manually adjusted one of .cbp files (corrected the output path). After CB reloaded the project file the corresponding .depend file was correctly generated.

On the other hand, at one point I removed all .depend files, reloaded and rebuilt the main workspace, but generated .depend were all empty (except the line: # depslib dependency file v1.0)

Offline tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #9 on: September 20, 2011, 12:17:21 am »
It looks I found how to trigger correct generation of .depend files: after I edited a .cpp file, saved it and built the corresponding project the related .depend file was correctly re-generated.

Offline tankist02

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: What's up with .depend files?
« Reply #10 on: September 20, 2011, 01:10:19 am »
And I also found that switching to a different workspace may re-write correct .depend files with empty ones.   :(

More details:

- Loaded a smaller workspace. Edited at least one .cpp file in each project. Built each project after the edit. .depend files are correct

- Loaded a larger workspace that included all the projects from the smaller one plus some more. Edited a .cpp file in a new project. Built the project. .depend file for that project became correct, but all other .depend files became empty.

From my experiments it looks that .depend generation algorithm contains a bug (at least on Linux x86_64) which may be triggered when a new "superset" workspace is loaded and built.

Perhaps it would be helpful to have a "manual overdrive" to re-generate .depend files, probably somewhere in advanced options.