Static Library vs Dynamic Linked Library (Lib vs. DLL)


The Kool Aid:
“Using dynamic linking instead of static linking offers several advantages. DLLs save memory, reduce swapping, save disk space, upgrade easier, provide after-market support, provide a mechanism to extend the MFC library classes, support multilanguage programs, and ease the creation of international versions.”

Lib

-This is a code “bundle” inside your .exe

DLL

-This is a stand alone unit of code.

Performance
  •  Code is always loaded with the executable
  • Can speed up app load time
  • Small hit when the .dll loads
  •  Can be deferred at App load time
Compiled Size
  •  Larger file size for .exe
  •  Many smaller files
ALM
  • Can only be used at compile time.
  • Not prone to versioning problems.
  • You will need to take extra steps to get the PDB’s rolled into the DLL PDB
  • Must update each product which uses it separately
  • Fights incompatibility issues
  • requires you to replace the exe for upgrades.
  • Some say Lib’s make it easier to support many platforms
  • Modularity
  • Can Be used by multiple Applications.
  • Can speed up development (reduced compile time)
  • Can cause versioning problems.
  • Can upgrade all products at once if dll is shared across product lines
  • Forces you to update all related projects and can cause compatibility maintenance issues across your organization.
  • Allows you to upgrade the application by replacing just the dll.
  • Can make it easier to support new hardware or hardware changes
Operation
  • Used by the compiler at compile-time.
  • Results in 1 Large file.
  • Avoids dependency issues
  • Compiled and called at runtime.
  • Results in many smaller files.
  • Can be stored in the GAC
Misc.
  •  All iOS binaries are static libs
  • Original implantation was the origin of DLL Hell
  • Your Exe will produce a minimal Lib file at compile time to link to the dll
  • Allow a game to easily support mods.
Architectural Consideration
  • Special care need to be taken when internal dependencies are not straight forward.
  • Allows for inter-process communication
Legal Implications
  • If you use an LGPL library statically your code automatically becomes Open Sourced
  • If you use an LGPL library then you only have to open source the changes made to that library/
Security
  • Everything is internal to the exe, thus contained
  • Data can potentially be ‘hacked’

If you are developing for windows 8 (win8)  then the quick answer is use a DLL

If your Developing for iOS then use a Lib

 

References:

About Larry Louisiana

I'm a Microsoft Partner Consultant.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment