Discussion:
Static libraries and dependencies
(too old to reply)
Seabass
2010-01-23 18:54:02 UTC
Permalink
Hey guys,

I'm trying to break my projects up a bit so I'm not rebuilding code
that hasn't been changed. So i split one of my static lib projects
into two. Lets call them LibA and LibB. Then there is my main project
which makes use of LibB. LibA depends on LibB and the main project
depends on LibB. Pretty straight-forward.

So now I am trying to hook them all up. When i build LibB, everything
is fine, it can find LibA and it all checks out. The problem comes
when I try to build the main project. The header of LibB has
references to classes in LibA, so when i build the main project, it
starts asking for LibA or if I remove the include to LibA, it can't
parse the classes since it doesn't know what they are. This may be a
"by design" thing, but it seems illogical to have to include LibA in
the main project when in fact LibB is already doing that.

Is there anyway around this? Perhaps I'm setting up my library headers
wrong?

Thanks!
Seabass
2010-01-23 18:57:15 UTC
Permalink
Sorry, I forgot to mention: I am using Visual Studio 2008.
David Wilkinson
2010-01-25 03:41:08 UTC
Permalink
Post by Seabass
Hey guys,
I'm trying to break my projects up a bit so I'm not rebuilding code
that hasn't been changed. So i split one of my static lib projects
into two. Lets call them LibA and LibB. Then there is my main project
which makes use of LibB. LibA depends on LibB and the main project
depends on LibB. Pretty straight-forward.
So now I am trying to hook them all up. When i build LibB, everything
is fine, it can find LibA and it all checks out. The problem comes
when I try to build the main project. The header of LibB has
references to classes in LibA, so when i build the main project, it
starts asking for LibA or if I remove the include to LibA, it can't
parse the classes since it doesn't know what they are. This may be a
"by design" thing, but it seems illogical to have to include LibA in
the main project when in fact LibB is already doing that.
Is there anyway around this? Perhaps I'm setting up my library headers
wrong?
What does "asking for LibA" mean? Are you talking about compiling or linking here?
--
David Wilkinson
Visual C++ MVP
Igor Tandetnik
2010-01-25 17:13:39 UTC
Permalink
Post by Seabass
I'm trying to break my projects up a bit so I'm not rebuilding code
that hasn't been changed. So i split one of my static lib projects
into two. Lets call them LibA and LibB. Then there is my main project
which makes use of LibB. LibA depends on LibB and the main project
depends on LibB. Pretty straight-forward.
There is no way to reference one static lib from another. When you set up dependencies in the IDE, you just tell the build system that you want LibB to be up to date (rebuilt, if necessary) whenever you build LibA (which is a rather pointless thing to require). But that doesn't do anything at all to cause a project that links to LibA to also automatically link to LibB.

You will have to have the EXE project depend on both LIBs. Having one also depend on the other, though harmless, doesn't really achieve anything useful.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Continue reading on narkive:
Loading...