CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Static lib question

    Is there a way to build a static lib so that it links in other static libs?

    In other words, if I build a lib A as a static lib, and it has a dependency on another static lib B. Is there a way for me to build A such that it incorporates the necessary parts of B so that I only have to ship A and not A and B?

    To give an example, I have a colleague who is building a library that has a dependency on boost thread. The interface header of his library uses pointer to implementation, and therefore does not expose anything unnecessary. The issue that he is having is that when he builds his library, he would like it to link in the required sections from boost thread so that when he builds a final application, the final application will not need the boost library at link time.

    Anyway, it's not obvious how to do this, or if it is even possible.

    Any advice would be appreciated.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Static lib question

    Of course. Just link in the other libraries as you would with any other project.

  3. #3
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: Static lib question

    For some reason that's not working. The library is not actually linking in the sections from boost thread that it requires when it links, therefore the final application is complaining that it needs the boost static lib in order to do the final link.

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Static lib question

    I didn't think that the linker does anything when building static libraries, other then to collect all the object files into one .lib file (in other words, nothing is actually linked).

    Have you looked at the Library Manager that comes with Visual Studio? This might suit your needs.

    Viggy

  5. #5
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: Static lib question

    Quote Originally Posted by MrViggy View Post
    I didn't think that the linker does anything when building static libraries, other then to collect all the object files into one .lib file (in other words, nothing is actually linked).
    That would explain it.

    Quote Originally Posted by MrViggy View Post
    Have you looked at the Library Manager that comes with Visual Studio? This might suit your needs.

    Viggy
    Thanks, I'll take a look.

  6. #6
    Join Date
    Nov 2003
    Posts
    1,902

  7. #7
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Static lib question

    Man... what's happened with my memory? Had totally forgot that post...
    Thanks for reminding me though Codeplug.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured