User forums > Using Code::Blocks

Dependencies on .hpp files not triggering [SOLVED]

(1/2) > >>

kfmfe04:
I have a static lib project with a bunch of .cpp files and .hpp files.

When I modify a .cpp file and build, the proper files get compiled and linked.
When I modify a .hpp file and build, I get:

Target is up to date.
Nothing is to be done.

I have tried it on .hpp files #include'd in a .cpp file and ones that are not.
All .hpp files are set to "Belong in targets: Debug and Release."

I don't know what I should do to ensure that a rebuild depends on changes in the .hpp files.  At least, it should rebuild on changes to MyClass.hpp if MyClass.cpp #include's it...

Any ideas where I should check for dependencies?
Thanks in advance.

kfmfe04:
Update: I right-click on MyClass.hpp and select Properties > Build > Compile file, which causes gcc to build a .gch file.

Now, if I modify a header file in my static library (unpleasant result):
1.  it causes the static library to build (GOOD)
2.  but my second project (executable) which depends on that static library does not link (BAD)

In contrast, if I modify a cpp file in my static library (good result):
1.  it causes the static library to build (GOOD)
2.  my executable project relinks (GOOD)

At this point, I am indifferent towards using .gch files or not - but I need the system to build and link the right files when I change a header file in the library, or development becomes quite difficult.

Any ideas what settings may be off?

Jenna:
Are the dependencies set correctly ?

Dependencies have to be set in projects "Properties  -> Build targets -> External dependencies -> External dependency files" , to make sure the executable is rebuild and or relinked, if the library changes
and in  "Properties  -> Project settings -> Project's dependencies", to make sure the library is updated (if necessary) before the executable gets build/linked.

kfmfe04:
Hi Jens,

Thank you for your suggestions.  

I tried both your suggestions, but it isn't working yet.  Those settings seem to affect relinks, but not recompiles.

I will be more specific.  

MyStaticLib:  libheader.hpp (no .cpp - implementation in header), other.cpp, other.hpp ...
MyApp:  app.cpp (#include's libheader.hpp) ...

---------------------------------------------------------------------------------
What I need is for app.cpp to depend on libheader.hpp so that it recompiles app.o when libheader.hpp changes.
---------------------------------------------------------------------------------

The two suggestions you had affect relinks, but not a recompile to app.o ...

If this is a limitation of C::B, I can probably script around this, but I am hoping, instead, that I am doing something wrong...

Regards,
Ken

(BTW, since it is a library, I should implement in .cpp instead, but there are special cases, like inline, that have to be in .hpp so it would be nice to get the dependencies right during development...)


MortenMacFly:

--- Quote from: kfmfe04 on July 07, 2009, 06:23:09 am ---MyStaticLib:  libheader.hpp (no .cpp - implementation in header), other.cpp, other.hpp ...
MyApp:  app.cpp (#include's libheader.hpp) ...

--- End quote ---
If app.cpp includes header.hpp of the "lib" than this works very well for me... (even if header.cpp does not have a cpp file)?!

Navigation

[0] Message Index

[#] Next page

Go to full version