Thread: what is the difference between a static and dynamic library
guys had googled , getting definitions same on links.here searched.
want real example of where, static , dynamic library being used.take example in ubuntu static library being used , dynamic library used?
first of all, http://en.wikipedia.org/wiki/dynamic...atic_libraries
when compile program, 1 of things "link" of libraries uses. so, instance, when #include <stdlib.h> @ top of c program, tell program functions in there exist, don't binary executable code atoi, exit, malloc, etc. code lives in library called libc, linked automatically compilers. if use other library, though, may have link manually using -l option gcc.
now, have static , dynamic? well, static library, entire library copied /lib (or wherever resides) inside program, , entire executable spat out, code , library code. dynamic library, however, library not copied. reference library included in executable, actual library code not. when call function in library, c runtime see if library need exists on current system. if does, , it's not in ram, load , allow use defined in it.
dynamic libraries have several benefits:
- smaller executable sizes
- less duplication - multiple programs depend on same library need 1 copy whole system
- less ram usage - same library can shared among different programs running @ same time
however, has issues:
- it slower, linking must done @ runtime instead of compile time.
- it must able find library @ runtime if exists on system. if doesn't exist or can't found, program can't run.
last point source of of "foo.dll not found" errors used on windows. .dll stands "dynamically linking library".
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk what is the difference between a static and dynamic library
Ubuntu
Comments
Post a Comment