User forums > Using Code::Blocks
Dependencies to static libs don't work?
cacb:
Hi,
I have a workspace with a couple of application projects both depending on a common static library project. I want to have it like that because the resulting builds are then self contained.
The application projects are defined to be dependent on the static library, and a full rebuild works fine. But I find that very often after I make a change in one of the .cpp files of the static library, and then build one of the applicatons (not complete rebuild), it reports that it is already up to date and does not re-link. This is not correct and very annoying as I keep running/debugging the wrong code.... I have to manually change one of the application source files to force a relink.
Have you seen this before, is there something I have missed?
cacb:
Nobody has any opinion on this? I am seeing this problem.
If a header files in the static lib project is changed, all is fine, the main project recompiles and relinks. If a .cpp file in the static lib is changed, the static lib is recompiled and a new.lib file is generated.
But the application project using the lib claims it is up to date and does not relink, resulting in wrong behaviour.
Jenna:
You can set dependencies to external files in the projects properties.
Right-click your project and chose "Properties -> Build targets". For every build target (e.g. Release, Debug) you can click on "Dependencies" and set the static lib(s) it depends on as external file.
If you want to make sure the lib is checked for changes and eventually build before the actual project, include the project containing the lib in "Project's dependencies" (on "Project settings" tab).
cacb:
Thank you Jens :D
I tried with the first technique, defining external dependencies, and that did in fact work.
But the project as such was already defined as depending on the lib using Project Dependencies ("Project Settings"). I would not have expected dependency to work without declaring a dependency....
I thought that when using Project Dependencies I would have an automatic dependency to the lib file as you explain. But it certainly does not work here (I am using build 5309 on Windows and Kubuntu). It seems odd to have to declare a project dependency AND declare external dependency to the project lib for every build target?
flobadob:
I can't even get my dependencies to build if they are missing. How does one setup dependencies correctly for, say, an exe project and a static lib project in the same workspace?
Navigation
[0] Message Index
[#] Next page
Go to full version