LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-12-2004, 01:46 PM   #1
earksiinni
LQ Newbie
 
Registered: Jun 2004
Posts: 3

Rep: Reputation: 0
Role of glibc in Linux, gcc, and ld


Hi, everyone. I'm trying to create a distribution of my own from scratch (no, not Linux From Scratch) and I wanted to know what the role of glibc is in a Linux system.

Do programs use glibc all the time and make calls to it constantly or is it used only during compilation and linking?

If glibc is the primary library for all programs, what's the difference between linking it dynamically and statically? Wouldn't linking it statically be redundant since it already has all the functions in it?

Finally, if I install the glibc libraries in a non-standard location (that is, not in /lib or /usr or whatever), how do I tell the configure scripts of other programs and the linker to look for the libraries in a different location? Or is it an environment variable?

Thanks very much!
-earksiinni
 
Old 06-12-2004, 04:04 PM   #2
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Rep: Reputation: 30
Here is a start:

"Any Unix-like operating system needs a C library: the library which defines the ``system calls'' and other basic facilities such as open, malloc, printf, exit...


The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel. "

--from http://www.gnu.org/software/libc/libc.html



As to your question:

"Finally, if I install the glibc libraries in a non-standard location (that is, not in /lib or /usr or whatever), how do I tell the configure scripts of other programs and the linker to look for the libraries in a different location?"

I think that is done with switches on the command line when you run the configure script. IE:

./configure --someswitch path/to/library

I believe you have to check the documentation of each install to know what the switches are
 
Old 06-12-2004, 04:50 PM   #3
earksiinni
LQ Newbie
 
Registered: Jun 2004
Posts: 3

Original Poster
Rep: Reputation: 0
hmm...alright, fair enough

it would be nice to know about compiling glibc statically and dynamically, though
 
Old 06-12-2004, 09:39 PM   #4
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Rep: Reputation: 30
Yes. but i dont know that answer. Hopefullt an expert will step in.
 
Old 06-12-2004, 11:03 PM   #5
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
first at the risk of popping you bubble by the nature of the question it appears you are in way over your head at this point. Beyond that
basically since libc is the core linux system for dynamic linking
libc-foo.so itself is dynamically linked only against ld.foo.so
obviously it needs to be built as a shared library. (position independant code)
If you make it static archive and we are just talking theory here because i would imagine that is imposible ! and or your system could never work at all this way
nor will you even be able to try without major hacking at the very least the Makefiles.
Every program that runs on your Linux system would have to be static and huge and contain all the peices of the clib that it uses within each binary.
plus you would have to hand write all the Makefiles for everything i think.
nothing would compile.
Plus you may be locked into creating every other library even as static archive as well.
Your system will run out of ram very quickly and run like crap if at all.
remember when you are saying glibc you are talking about
BINARIES: catchsegv, gencat, getconf, getent,
glibcbug, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale,
localedef, mtrace, nscd, nscd_nischeck, pcprofiledump, pt_chown,
rpcgen, rpcinfo, sln, sprof, tzselect, xtrace, zdump and zic
LIBRARIES: ld.so, libBrokenLocale.[a,so],
libSegFault.so, libanl.[a,so], libbsd-compat.a, libc.[a,so],
libc_nonshared.a, libcrypt.[a,so], libdl.[a,so], libg.a, libieee.a,
libm.[a,so], libmcheck.a, libmemusage.so, libnsl.a,
libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so,
libnss_nis.so, libnss_nisplus.so, libpcprofile.so,
libpthread.[a,so], libresolv.[a,so], librpcsvc.a, librt.[a,so],
libthread_db.so and libutil.[a,so]

build Linux from Scratch about 12 times and 12 different ways then start asking these kinds of questions i think
 
Old 08-29-2005, 04:04 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,110
Blog Entries: 4

Rep: Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210Reputation: 3210
Explanation of "static" vs. "dynamic" linking:

All programs rely very heavily upon a library of subroutines, from the mundane to the ridiculous, which are not present in the source-code that you have written but that are "assumed" to exist. And they do exist, in a library such as glibc.

In order for the program to actually run, howeve, those "other" routines must somehow be brought together with your program, to create one complete mass of executable code wherein "everything is there." That's "linking."

With static linking, all of those various routines are brought together at compile-time and placed into one, necessarily rather-large but also self-contained, executable file.

With dynamic linking, that joining-together process occurs at runtime. And furthermore, if (as is usually the case) several programs are all sharing the same library, just one copy of that library will reside in-memory and all of those programs will share it. The executable file is smaller, no-longer self-contained, and takes a little more time to start running.
 
  


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
Linux Support role? venkat_bommireddipal Linux - Certification 1 09-15-2005 01:31 PM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 02:13 PM
Mplayer compilation problem on linux 2.6.3 gcc 3.3.3 glibc 2.3.2 realloc Linux - Software 4 10-22-2004 03:44 PM
gcc 3.4.0 and glibc ralam Linux From Scratch 8 05-06-2004 12:19 PM
just wondering.. what is the role of glib or glibc or whatever..? kublador Linux - Newbie 5 07-28-2003 01:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration