1753808 Members
8231 Online
108805 Solutions
New Discussion юеВ

Links

 

Links

Hi,
What is Dynamic Link and static Links In Unix.

Whats the Use???
How to do U link it.

Rgds
Raghu
3 REPLIES 3
G. Vrijhoeven
Honored Contributor

Re: Links

Hi Raghu,

Do you mean symbolic links and hard links ( ln / or ln -s ) check man ln.

Or do you mean how do you link executables. There are Dynamicly linked and staticly linked executabeles. ( /usr/bin ( is a link to /bin, and /sbin) use file to check.

So they are both used.

Gideon
ranganath ramachandra
Esteemed Contributor

Re: Links

put simply, static linking results in a binary that has all the code from the input object files and libraries in the final executable.

dynamic linking makes use of the fact that many programs tend to use some common libraries. so libraries (like libc) are shared at runtime amongst processes. their code (not data) is actually loaded only once into memory. this also reduces the size of the executable file.

for details, see the hpux linker and libraries user guide at
http://docs.hp.com/hpux/onlinedocs/B2355-90654/B2355-90654.html
specifically the section about creating and using libraries:
http://docs.hp.com/hpux/onlinedocs/B2355-90654/00/00/44-con.html
 
--
ranga
[i work for hpe]

Accept or Kudo

Sridhar Bhaskarla
Honored Contributor

Re: Links

Hi,

In addition to Ranganath's message, you can find the statically linked binaries under /sbin. They are meant for single user/lvm maintenance mode as /usr/lib may not be available during that time.

Statically linked binary will have all the machine code required for it to run. Dynamically linked binary will have only references to where to find the libraries that have the necessary machine code.

For cc, you can use "-dynamic" for the linker to generate dynamically linked executables. This is default. For statically liked ones, you will need to explicitly specify -noshared option with cc.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try