Results 1 to 7 of 7

Thread: static & dynamic linking

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default static & dynamic linking

    Anyone can tell me any "GOOD" link where found explanation about linking? (.lib, .dll, how to link and why and when).
    Thanks.
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: static & dynamic linking

    no link but maybe a short explanation :

    there are two kinds of linking :
    • inside an app : specific to OOP. A function can be statically or dynamically linked depending on the use of the 'virtual' keyword. This is a very important thing but I guess it's not what you're talking about

    • between app and lib : function, classes, ... can be dynamically or statically linked depending on the type of lib. A static lib contains everything the API offers to coder, linking an app to it just add the corresponding code to the program. Linking to a shared lib just add a bit of instructions hold in a static lib. These instructions locate the shared lib and import everything you want from it. Static linking causes a bigger size but gives better control over versions and ensures everything needed to run the app is avaiable. Dynamic linking reduces size, allow easier upgrade but may causes bugs due to absence of backward compatibility between two versions of a lib. Deciding when to use them is up to you and depend on how your app behave...
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jan 2006
    Posts
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: static & dynamic linking

    a nice intro to dll usage can be found here

  4. The following user says thank you to edb for this useful post:

    mickey (21st April 2006)

  5. #4
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: static & dynamic linking

    The link can not be opened, who can give a valid link? Thanks!

  6. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: static & dynamic linking

    Quote Originally Posted by learning_qt View Post
    The link can not be opened, who can give a valid link? Thanks!
    it is a post of 2 years ago. The link worked. Sincerly I don't remember the link.
    Regards

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: static & dynamic linking

    Some pros and cons have been listed in our wiki: [WIKI]Building static applications[/WIKI].
    J-P Nurmi

  8. #7
    Join Date
    Jun 2010
    Posts
    31
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: static & dynamic linking

    Having static libraries work with qmake seems to require quite a bit of black magic. I've tried getting it working with the prebuilddefs, the postbuild defs, and the createprl methods of having static libraries properly recognize library dependencies during compilation. The only method that I've found that works is tweaking the order in which static libraries are compiled in order to resolve any linking errors.
    I have found that the documentation online is frustratingly sparse and that a lot of the links to documentation are dead. So when trying to decide whether or not to use static or dynamic linking, keep in mind that you will have to deal with a few headaches to get everything linking properly.
    Something that I haven't successfully gotten to work with static linking is the addition of the -( and -) flags that you can add straight to the ld linker. It seems like these flags are not recognized by the LDFLAGS you can place in a .pro file. Also, those flags really add to your compilation time, however when using them you don't have to deal with re-ordering of libraries.

Similar Threads

  1. Static linking of Qt programs
    By divya balachandran in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2008, 12:10
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Qt 4.3 static linking on Windows
    By john_crichton in forum Installation and Deployment
    Replies: 2
    Last Post: 13th May 2008, 06:57
  4. Replies: 2
    Last Post: 1st August 2007, 15:04
  5. Replies: 4
    Last Post: 20th February 2006, 09:11

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.