Jump to content
  • Advertisement
Sign in to follow this  
sfx81

static Libraries

This topic is 2568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, just a generic questions relating to static libraries.

If I create a static library A, which has code dependent on another static library B, then I use static library A in one of my Dll's, does it mean I dont have to include library B to my dll ?. In otherwords, will the dependent code in library B be burnt into library A, so library A will have its own code plus any additional code from library B ?

Will appreciate any help + links.
Thanks

KAZ.

Share this post


Link to post
Share on other sites
Advertisement
Depends on how you configure your linker, but yes, you can do this. Just try it and you'll probably find that's how your compiler does it by default.

Share this post


Link to post
Share on other sites

If I create a static library A, which has code dependent on another static library B, then I use static library A in one of my Dll's, does it mean I dont have to include library B to my dll ?. In otherwords, will the dependent code in library B be burnt into library A, so library A will have its own code plus any additional code from library B ?


A good conceptual model for static library is "bundle of object files". So unless you've explicitly put all the objects from B in to A as well, you'll have to tell the linker about both of them. In fact if you're using the GCC linker, you'll also have to get the order right too. The Visual C++ linker tends not to be too fussy.

Share this post


Link to post
Share on other sites
I had a question relating to this...

Say static library A depends on static library B full of useful utility functions.

Now also main project depends on both A and B. Is the executable bigger because library B is linked in twice or is it only linked in once?

Share this post


Link to post
Share on other sites

Say static library A depends on static library B full of useful utility functions.

Now also main project depends on both A and B. Is the executable bigger because library B is linked in twice or is it only linked in once?

If both A and B are static libraries, there is not copy of B 'inside' A, so nothing is linked twice. In fact linking something twice will likely give you a linker error (depending on the linker) relating to the existence of multiple definitions for a bunch of symbols.

Again, you won't go far wrong if you think of a static library as a bundle of object files. Unless you've put copies of the same object files in both A and B, you won't have duplicate code/data anywhere.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!