Sign in to follow this  

Difference between a DLL and a Static Library

This topic is 4746 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

WHat is the difference between a Direct Linking Library and a Static Library? I know how to make a Static Library in DevC++ when getting a new API but sometimes they provide the DLL and sometimes they don't. For the don'ts, I usually have to find one somewhere else instead Why do I need both and how do I make one?

Share this post


Link to post
Share on other sites
Plus some compilers need a small static library with the definitions of everything inside the DLL in order to compile correctly against the DLL.

Using a DLL keeps your app small, but creates dependencies. Using a static lib increase executable size, but there are no dependencies to other libs. Best solution varies per app.

hth
CipherCraft

Share this post


Link to post
Share on other sites
Quote:
Original post by Yamian
WHat is the difference between a Direct Linking Library and a Static Library?

It relates to the time at which the call to a function within the library is resolved. A static call is one which gets resolved at link-time (hence the code being called will get compiled into the final executable image alongside your own code). A dynamic call is resolved at runtime. There's a different calling protocol required for each of those, which is why you have different configurations of the library for static and dynamic linking.

Share this post


Link to post
Share on other sites
There are actually three types of library:
  • Static Library
    A static library contains the compiled code for the library. When linking against a static library the linker copies all of the required code into your executable, thus increasing the size of your executable but ensuring that you only need to distribute the executable and not the library.

  • Dynamic Link Library
    A dynamic link library also contains the compiled code for the library. However, the DLL is not linked at compile-time. Instead the program interfaces with the library at run-time. This means your executable can be smaller, but if the client doesn't have the DLL you'll have to distribute that as well.

  • Static Import Library
    In order to use a DLL your executable needs to know which DLL to use and what functions it contains. A static import library contains a list of all the functions exported by the DLL so that the compiler can generate all the function calls to the DLL automatically. The alternative is to load the DLL and the functions you require manually.


Enigma

Share this post


Link to post
Share on other sites
As described above, there's a difference between static and dynamic linking. One thing that I think got overlooked, though, was that if you have a library that isn't going to be used by other applications, you might as well make it static.

That is, suppose you have a library which manages your game engine. It is highly unlikely that the user will be running multiple copies of your game, and also unlikely that other applications will need access to this library. In this case, it's a smart move to make your library static; you'll get a modest performance gain.

Share this post


Link to post
Share on other sites
Quote:
Original post by kSquared
As described above, there's a difference between static and dynamic linking. One thing that I think got overlooked, though, was that if you have a library that isn't going to be used by other applications, you might as well make it static.

I think that heuristic is too simple. There may be benefits to be realised in making a DLL that is consumed by a single app. For example, if an application consists of multiple concurrent processes, or if components are optionally loaded at runtime.

Share this post


Link to post
Share on other sites

This topic is 4746 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this