LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices

Reply
 
Search this Thread
Old 02-14-2002, 09:34 AM   #1
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Rep: Reputation: 30
Static-ly Linked...


I was reading this in the 3.1 book about bash:

--enable-static-link: This configure option causes Bash to be linked statically

what does statically linked mean?
 
Old 02-14-2002, 09:47 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
when programs are statically linked, they take the external libraries and compile them directly into the program object. this makes the program much larger, and i presume can slow it down, but means that it doesn't rely on external libraries existing for it to run.
 
Old 02-14-2002, 10:00 AM   #3
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
Question huh?

"when programs are statically linked, they take the external libraries(<---what are those??) and compile them directly into the program object(<--what is this). this makes the program much larger, and i presume can slow it down, but means that it doesn't rely on external libraries existing for it to run."

sorry man... i am just not that smart
 
Old 02-14-2002, 10:07 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Re: huh?

Quote:
Originally posted by Chijtska
"when programs are statically linked, they take the external libraries(<---what are those??) and compile them directly into the program object(<--what is this). this makes the program much larger, and i presume can slow it down, but means that it doesn't rely on external libraries existing for it to run."

sorry man... i am just not that smart
hehe, ok.

libraries: external files that contain useful funtions that many programs might want to use. These are typically the .so files

program object.. ahh just mean the program, eg "/bin/bash"
 
Old 02-14-2002, 10:07 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Re: huh?

Quote:
Originally posted by Chijtska
"when programs are statically linked, they take the external libraries(<---what are those??) and compile them directly into the program object(<--what is this). this makes the program much larger, and i presume can slow it down, but means that it doesn't rely on external libraries existing for it to run."

sorry man... i am just not that smart
hehe, ok.

libraries: external files that contain useful funtions that many programs might want to use. These are typically the .so files (dll's in windows)

program object.. ahh just mean the program, eg "/bin/bash"
 
Old 02-14-2002, 10:32 PM   #6
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
ok... the .so files are like the extra functions that a biger program can use without the writer having to actually write them again... did i get that right? makes a lot more sense to me now lol
thanks
 
Old 02-15-2002, 12:57 AM   #7
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
The magic word here is "binding". Binding is the term used to describe when compiled object modules are "bound" together to form a complete executable program. Basically there are two types of binding; static and dynamic. Static binding is done at compile time and dynamic binding is done at run time.

If you look in /usr/lib you will find a libc.a and a libc.so. Each of these files contain code generated from compiling the standard c library functions. The source code is compiled with a compiler option to generate a static library and generates the .a file. The same source code is compiled with a compiler option to generate a dynamic library and generates the .so file.

Now, you compile a program and tell the compiler (actually the linker) to use static binding. The linker will actually pull the required code from libc.a and put it into the generated object program.

You compile the same program and tell the compiler to use dynamic binding. Instead of putting the required code into the generated object file, it will only put the path name of the libc.so file. Later, when the program is actually executed, the libc.so is used for the required code. This should explain why the missing library errors come up when you execute a program.

There are tradeoffs for static and dynamic binding. Static bound programs take more disk space but start up quicker. Dynamic bound progarms are smaller but take longer to start up. This is mainly because the libc.so file must be found and opened at execution time. There are other considerations also. but it is late.

Hope this helped...
 
Old 02-15-2002, 07:55 AM   #8
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
Thanks for the help... I have always wanted to understand libraries and their functions...also why there are static and dynamic ones and why... that made a good deal of sense to me...

thanks
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto Assign Multiple Static Public IP Addresses under SBC's PPPoE Static Ip system o trekgraham Linux - Networking 8 04-17-2007 10:51 AM
Is there any static ARP for static IP network? linux_lover2005 Linux - Networking 2 05-18-2005 12:01 PM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 11:13 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
Winxp linked to Linux Linked to home network OverboardKiller Linux - Networking 2 06-09-2003 09:59 AM


All times are GMT -5. The time now is 10:50 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