How Configure Shared Library Difference Between Static Dynamic Library .a .so


Whenever we install the Open source Application or Software Read me file Instruct us to add directory of shared Library to $LD_LIBRARY_PATH Environment Variable to /etc/.bashrc file.
$LD_LIBRARY_PATH - Environment Variable for Shared Library Loader.

Difference Between Shared Library Files .a .so
Libraries are linked Either statically or Dynamically.
.so files are DYNAMIC library files.
which are loaded /unloaded and linked to an Executable at runtime.dynamic Library-Not copied into executable , but it will automatically load libraries at run time.
.a files are STATIC library that get linked to code at a compile Time.
To check the Shared library Dependency we can use ldd command.
It is an ar archive

Shared Library Files Configure Important command.
ldd- List Dynamic Dependency.
# ldd /usr/bin/w – These are Dynamic Dependency files for w binary files. => /lib/ (0x00cb5000) => /lib/tls/ (0x00b8a000)
/lib/ (0x00b6d000)

How to Configure Shared Library permanently .
Add New Library Path into /etc/ (or) We have to add Any Library Path with library-path-file-name.conf extension

/etc/ like /etc/
Activates the Path

lddconfig - Configure Dynamic Link Library.
For confirmation (or) Verification
#ldconfig -v | grep "New Library Path"

ldconfig - configure dynamic linker run time bindings.
Common Library Path.
/usr/lib Standard System Libraries.
/usr/X11R6/lib/ X11 Libraries.
How to Compile the Program with Shared Library for X server Program
#gcc -Wall program.c -o output -L /usr/X11R6/lib -l X11
-L share Library Directory
-l Search
-Wall Warning Message
#ld - GNU Linker

.a represents static library.

.so represents dynamic library.
.a it is achieve file So it is shared object file.
Static Library linking to the Source code while compile time and generate the Object code. Dynamic Library linking to the Executable file at the Run Time.
1)While compilation library is passed through –L <option) (or) LD_FLAGS (or) in the makefile we will know the LDFLAGS option.
2)using #nm OBJECT_FILE | grep LIBRARY-NAME (we know the library details).
Example :
# nm ex4.o (List The Symbol From Object File)
000000000000000c C ilower
0000000000003201 T initialize
0000000000004daf T iterate
0000000000000004 C itr
000000000000000c C iupper
000000000001911a T main
U memcpy
0000000000000004 C myid

To Find What Are Libraries are used We have to used.
#ldd (command)
For Example.
2)# ldd /usr/bin/wine => (0xffffe000) => /usr/bin/../lib/ (0x009de000) => /lib/ (0x0060b000) => /lib/ (0x004a9000) => /lib/ (0x00604000)
/lib/ (0x00486000)

No comments:
Write comments