This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can gcc and Linux create a dynamic library?
- From: ali hagigat <hagigatali at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: iant at google dot com
- Date: Sat, 25 Dec 2010 11:02:45 +0330
- Subject: Can gcc and Linux create a dynamic library?
Thank you Ian.
How can i request gcc to create a dynamic library(not a shared
library)? When we create a dynamic library, there will be multiple
copies of the code of that library in the main physical memory for
each program which uses that library?
If there is always one copy for the library: Considering that library
has some global variables and functions and program A changes those
variables, then program B starts up and uses the same library. Then B
can not use the same initial state as A. Is that right?
Regards
> from Ian Lance Taylor
> Your understanding is misleading because when you link the program it
> gets a list of the dynamic libraries that it requires. When the program
> starts up, the dynamic linker finds those dynamic libraries and adds
> them to the address space. That is, the dynamic library is not added
> when the variable is referenced. It is added when the program starts
> running.