LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-11-2006, 03:04 PM   #1
swiadek
LQ Newbie
 
Registered: Feb 2006
Distribution: Ubuntu v5.1
Posts: 16

Rep: Reputation: 0
Binary -- static or dynamic ?


Binary -- static or dynamic ?

When should a Dynamic binary be considered ?

When should a Static binary be considered ?

Can you please explain differences, similarities, etc. between static and dynamic Binaries ?
 
Old 02-11-2006, 04:25 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,131

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Do you mean you're curious about when to link a binary statically or dynamically? A statically linked binary has all of the required library code built in, so it's big (wastes disk space) but will run on just about any system of the same type it was compiled on. If the binary is dynamically linked (uses shared libraries), all systems it is to run on must have a copy of all the required libraries.
 
Old 02-11-2006, 04:25 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
The difference:
a statically linked executable will hold all required binary code
inside it, e.g. even a simple hello-world will be over 1MB in
size.
a dynamically linked executable will look for the libraries it's
linked against at runtime, will be small. If you run several
instances (or if other programs have requested those libraries)
they'll only be loaded into RAM once.

The only two valid reasons to use static linking as far as I'm
concerned are:
a) If your system is set-up as multiple mount-points/file-systems
and you can't be sure that the filesystem with the libs will be
available at runtime, or you're worried that an upgrade of the
libs may render the system unusable (e.g. Solaris default shell
for the user root is statically linked)
b) You're distributing a binary without source, and can't make
any assumptions as to what the target system will have installed
in terms of libs.


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Addressing static and dynamic Hockeyfan Linux - Networking 1 10-24-2005 07:06 PM
Dynamic IP to Static Temujin_12 *BSD 2 06-10-2005 04:58 PM
Static vs Dynamic Big Al Linux - Networking 2 12-08-2003 03:10 PM
NS with static or dynamic IP cijunet Linux - Networking 3 05-08-2003 11:04 PM
C++, when to go for static or dynamic variables? linuxlah Programming 21 02-05-2003 08:38 AM


All times are GMT -5. The time now is 05:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration