+ 3

Static vs dynamic library

Hi We know that static library code gets embedded into main exe and changing the static lib doesnot change exe output... Where as in case of dynamic library, we can change the dll and exe considering that DLL need not to be updated... Also due to code embedded into exe, size of exe will be more in compared to dynamic library.. Apart from these, is there any difference between the two in terms of memory and / or speed ? On what basis we should be choosing between static and dynamic library? Another (off topic may be ) query is that my class has one member each into public, private and protected sections.... These code is getting used into main programme generating exe... Does the access specifier into the exe depends where class is defined (into dynamic or static library)? P.s. can we define that our generated static library works only with specific verson of visual studio?

20th Jun 2020, 4:01 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 odpowiedzi
+ 1
Ketan Lalcheta One advantage of dynamic library is that it can be shared by more than one application It uses less memory compared to the statically linked Library.
22nd Jun 2020, 2:47 PM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
+ 1
Thanks DHANANJAY PATEL ... Does this mean that two exe using same lib file doesnot work at same time provided all three files are in same folder ?
22nd Jun 2020, 4:35 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
If you are saying in terms of memory loaded by two different exe , how one exe can utilise memory from other process space ?
22nd Jun 2020, 4:36 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
It uses same DLL if it is loaded it reuses it. It requires re-enterent procedure and function DLL so that execution complete without any problem.
22nd Jun 2020, 4:47 PM
DHANANJAY PATEL
DHANANJAY PATEL - avatar