Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313
Rep:
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. "
"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
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.