I got some question regarding the shared and static libraries.So let me tell you what i did is, I have created a static library and also a shared library using the gcc commands and the size of libarith.a is 6KB and size of libarith.so is 18KB.Both the libraries contain the same functions.
I used one simple function(say add(a,b)) in my make.c file and linked the static library using these gcc command,
gcc -L/cygdrive/c/cpros make.c -larith.a # used a static library
the size of the exe file is 16.1 KB.
Next I used the same function(same add(a,b)) in my make.c file but these time using shared library, like these.
gcc make.c /cygdrive/c/cpros/libarith.so #used a shared library
unfortunately the size of exe file is 12.1 KB. I wonder how? becuase the size of libarith.so is 18 KB when compared to libarith.a which is just 6 KB.But at the end the exe file generated using the shared library is less compared to static library.
Can anyone give me a good reason for that ? If shared libraries consume less memory then why dont we go for shared libraries all the time.Please let me know when do we use shared libraries and when do use static libraries.
Yes when I was creating a shared library using -fPIC it gave me a warning position independent code. What does that warning actually mean?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)