By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,537 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,537 IT Pros & Developers. It's quick & easy.

How to get the information of the dynamic linkink library in UNIX?

P: n/a
Hi all,

1> If there are more than one dynamic linking libraries in the file
system, how do I know which one is loaded into system? Any C library
or system call can tell me which *.so or *.sl is active? Can the
setting of LD_LIBRARY_PATH guanrantee that the correct one is
executed?

2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
will be used by the subsequent appication. Does UNIX have the same
mechanism?

3> Or in UNIX the application always load the dynamic linking library
according to the paths specified by LD_LIBRARY_PATH.

4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???
Thanks for your help.
Regards,

K.S.Liang
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
K.S.Liang wrote:
Hi all,

1> If there are more than one dynamic linking libraries in the file
system, how do I know which one is loaded into system? Any C library
or system call can tell me which *.so or *.sl is active? Can the
setting of LD_LIBRARY_PATH guanrantee that the correct one is
executed?

2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
will be used by the subsequent appication. Does UNIX have the same
mechanism?

3> Or in UNIX the application always load the dynamic linking library
according to the paths specified by LD_LIBRARY_PATH.

4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???

And your C question is?
[hint: on news:comp.unix.programmer this might be appropriate]

--ag

--
Artie Gold -- Austin, Texas

Nov 13 '05 #2

P: n/a
ks*****@evercad.com (K.S.Liang) wrote:
# Hi all,
#
# 1> If there are more than one dynamic linking libraries in the file
# system, how do I know which one is loaded into system? Any C library
# or system call can tell me which *.so or *.sl is active? Can the
# setting of LD_LIBRARY_PATH guanrantee that the correct one is
# executed?

Different unices have different mechanisms and different guarentees. There's no
universal unix answer. Darwin, for example, allows one path to the library to
be compiled into the code, and then searches a predetermined list of
Library directories.

# 2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
# will be used by the subsequent appication. Does UNIX have the same
# mechanism?

Sometimes different members of a library may be crosslinked to prefer other members
of the same library rather than a previously loaded definition of a symbol. Depends
on the unix and how the libraries are constructed.

# 3> Or in UNIX the application always load the dynamic linking library
# according to the paths specified by LD_LIBRARY_PATH.

Not all unices even look at any environmental variable.

# 4> Can the applications belonged to different user share the same
# dynamic linking library? If not, how could it be called shared
# library???

A library or executable file consists of read only pages and pages that can be
modified by the program. Usual virtual memory semantics require changes to
pages to be isolated from other processes: these pages cannot be shared by
different processes. Read only pages will always be the same in every process
that loads them: they can be shared. The shared means more than one process can
have the same page in their different address spaces. Read only pages of executables
can also be shared.

A shared library is either loaded at the same vm address everytime (which can lead
to conflicts if two libraries load at the address), or the library code is compiled
so that its code pages can be loaded at any addresses without modifying the code
(using PC-relative branches or jumps through special linkage pages).

Static library code is copied into the executable file. The code can contain
relocatable addresses that are modified as it is loaded into the executable, modifying
the code pages when copied into the executable, but not modified while the
executable itself is running. As far as I know static libraries are no longer
linked dynamically in a running program: shared libraries can do this better
and cheaper. The static library file itself need not be present when the executable
is running: all relevant parts of library have already been incorporated into the
executable.

Different applications belonging to different users can share the same dynamic
library pages. Most unix programs use the C library; the kernel can arrange it so
there is only single copy of the library code in vm. This can greatly reduce the
number of pages required to run programs. Different applications of the same user
can share library pages. The same application in different processes (different
or same users) can share the executable pages.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
JUSTICE!
Justice is dead.
Nov 13 '05 #3

P: n/a
Derk Gwen <de******@hotpop.com> wrote:
ks*****@evercad.com (K.S.Liang) wrote:

[...]
4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???


A library or executable file consists of read only pages and pages that can be
modified by the program. Usual virtual memory semantics require changes to
pages to be isolated from other processes: these pages cannot be shared by
different processes. Read only pages will always be the same in every process
that loads them: they can be shared.


Even writeable pages can be shared between processes, if the OS supports
Copy-On-Write semantics for pages.

- Kevin.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.