Dynamic Libraries vs Static Libraries.

by raulzito234

When coding and trying to port MATLAB code to a C++ application I ran into some problems loading some dynamic libraries. See last post for more information

I never understood what was the difference between dynamic libraries and static libraries and the need for it. So I decided to learn it.

What is the difference between a dynamic library and a static library:

Dynamic libraries are not loaded to the executable code of a binary application. They are loaded in the fly. Dynamic libraries are not loaded into the heap.

Static libraries is compiled with the application and is kept together with the application. Wasting precious heap memory. [1]

I’ve seen many times articles referencing the heap and stack and I never understood the difference between the two, so I decided to google it.

What is the difference between stack and heap?

The stack is where memory is allocated for automatic variables.

Heap is a more stable storage than the stack. Memory allocated in the heap is there until the application is closed.

PS: For a more in depth explanation please visit the following websites:

[1]https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html#//apple_ref/doc/uid/TP40001873-SW1

[2] http://www-ee.eng.hawaii.edu/~tep/EE160/Book/chap14/subsection2.1.1.8.html

Advertisements