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.
libproc-3.2.3.so => /lib/libproc-3.2.3.so (0x00cb5000)
libc.so.6 => /lib/tls/libc.so.6 (0x00b8a000)
/lib/ld-linux.so.2 (0x00b6d000)

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

/etc/ld.so.conf.d/ like /etc/ld.so.conf.d/myapp.conf
Activates the Path

lddconfig - Configure Dynamic Link Library.
#ldconfig
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




STATIC LIBRARY DYNAMIC LIBRARY
.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
linux-gate.so.1 => (0xffffe000)
libwine.so.1 => /usr/bin/../lib/libwine.so.1 (0x009de000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0060b000)
libc.so.6 => /lib/libc.so.6 (0x004a9000)
libdl.so.2 => /lib/libdl.so.2 (0x00604000)
/lib/ld-linux.so.2 (0x00486000)

Related post