Kris Warkentin <kewarken@qnx.com> wrote in message
news:ar0fro$19k$1@nntp.qnx.com…
“zhz_zhang” <> zhz_zhang26@sina.com> > wrote in message
news:aqvmdm$g5o$> 1@inn.qnx.com> …
2.When I use c library (libc.so) function such as printf(…).We don’t
use dlopen()
or dlclose() function to load the library to memory.But we can use the
printf() function
at once.Why? So I think that The libc.so seems not Statically linked
lib,I think that it
seems not Dynamically linked lib either.
So what style-lib the libc.so is?
libc of cause is Dynamic linked lib. The fact you didn’t call dlopen() just
means, somebody
loaded it for you (before your main() get called).
When you linking your program, you (or the linker) already decided it will
need Dynamic
Linked libc.so, the information is stored in your binary, and when you
asking to run
your program, somebody (the loader) deicded to load that for you.
objdump -x on your binary, you would see “NEEDED” lines, which telling
loader what
THIS binary needed before it’s main() get called.
3.Where does the Dynamically linked library used in normally?
The most common usage of shared libs is just as you describe with libc.
Code sharing. Since almost every application need libc, (yeah, they may not
need
the whole libc but …) it make sense to have one copy of libc exist in
memroy, everybody
call into it, then every application have their own copy of (partial) libc.
Dynamic processing (plug in): You wait until seeing the incomming data, and
decided
it is, let’s say, a mpeg2 stream, then you dlopen() a mpeg2-codec.so, pass
the stream
to it…
-xtang