View Full Version : static & dynamic linking

16th April 2006, 17:41
Anyone can tell me any "GOOD" link where found explanation about linking? (.lib, .dll, how to link and why and when).

17th April 2006, 21:49
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...

21st April 2006, 11:49
a nice intro to dll usage can be found here ( ham%2Ftechnote%2F%2F%2Fmain.cgi%2FMS.pdf%3Fdown_nu m%3D1087299875&btnG=Zoeken&lr=)

16th December 2008, 12:37
The link can not be opened, who can give a valid link? Thanks!

16th December 2008, 16:58
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.

16th December 2008, 18:44
Some pros and cons have been listed in our wiki: Building static applications.

11th June 2010, 09:57
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.