Results 1 to 5 of 5

Thread: VC static linking lib with another lib

  1. #1
    Join Date
    Jun 2006
    Posts
    43
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default VC static linking lib with another lib

    I lack knowledge of VC's linking and how it works. I am still trying to get up to speed with the benefits and limitations of DLLs vs. .lib thing.

    I have a static library (call it a.lib) and want to make another static library (b.lib) that makes calls into a.lib. Then b.lib will be linked with application (c.exe).

    Is there any way to export the required symbols from a.lib into b.lib so that c.exe only needs to link with b.lib? I am looking to avoid explicitly linking a.lib into c.exe.

  2. #2
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: VC static linking lib with another lib

    All of their external symbols are deferred until they are linked into something that isn't a static lib. That is: a static lib is not built - it has no linkage stage. Make sense? A static lib with a source tree like a.cpp, b.cpp, c.cpp would be comprised of what would be a.obj, b.obj, c.obj. It is merely an object code container and not an actual binary image, it's a binary blob that the linker understands how to use. It's simply more convenient to distribute than a.obj, b.obj, c.obj.

  3. The following user says thank you to Timoteo for this useful post:

    Mookie (18th November 2010)

  4. #3
    Join Date
    Jun 2006
    Posts
    43
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: VC static linking lib with another lib

    Understood.

    Just as a side question. I assume the same applies for statically linked gcc libraries?

  5. #4
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: VC static linking lib with another lib

    Technically a static lib = an intermediate object = implementation detail = undefined. To answer your question more practically: yes.

  6. #5
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: VC static linking lib with another lib

    To get the behavior you want you need dynamic linking. b.dll will look for a.dll when loaded, and c.exe will start looking for b.dll when loaded.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Static linking with Qt
    By prykHetQuo in forum Qt Programming
    Replies: 3
    Last Post: 3rd June 2009, 21:56
  2. Static linking
    By didcea in forum Qt Programming
    Replies: 0
    Last Post: 11th October 2008, 19:40
  3. gentoo qt4 static linking
    By powermax in forum Newbie
    Replies: 1
    Last Post: 27th April 2008, 22:11
  4. Static linking problems.
    By Unplugged in forum Newbie
    Replies: 8
    Last Post: 17th February 2008, 03:25
  5. static linking issue
    By ashwini in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2006, 13:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.