1 Frequently Asked Question on GNU C Library
3 As every FAQ this one also tries to answer questions the user might have
4 when using the package. Please make sure you read this before sending
5 questions or bug reports to the maintainers.
7 The GNU C Library is very complex. The building process exploits the
8 features available in tools generally available. But many things can
9 only be done using GNU tools. Also the code is sometimes hard to
10 understand because it has to be portable but on the other hand must be
11 fast. But you need not understand the details to use GNU C Library.
12 This will only be necessary if you intend to contribute or change it.
14 If you have any questions you think should be answered in this document,
19 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
20 [Q1] ``What systems does the GNU C Library run on?''
22 [Q2] ``What compiler do I need to build GNU libc?''
24 [Q3] ``When starting make I get only error messages.
27 [Q4] ``After I changed configure.in I get `Autoconf version X.Y.
28 or higher is required for this script'. What can I do?''
30 [Q5] ``Do I need a special linker or archiver?''
32 [Q6] ``Do I need some more things to compile GNU C Library?''
34 [Q7] ``When I run `nm -u libc.so' on the produced library I still
35 find unresolved symbols? Can this be ok?''
37 [Q8] ``Can I replace the libc on my Linux system with GNU libc?''
39 [Q9] ``I expect GNU libc to be 100% source code compatible with
40 the old Linux based GNU libc. Why isn't it like this?''
42 [Q10] ``Why does getlogin() always return NULL on my Linux box?''
44 [Q11] ``Where are the DST_* constants found in <sys/time.h> on many
47 [Q12] ``The `gencat' utility cannot process the input which are
48 successfully used on my Linux libc based system. Why?''
50 [Q13] ``How do I configure GNU libc so that the essential libraries
51 like libc.so go into /lib and the other into /usr/lib?''
53 [Q14] ``When linking with the new libc I get unresolved symbols
54 `crypt' and `setkey'. Why aren't these functions in the
57 [Q15] ``What are these `add-ons'?''
59 [Q16] ``When I use GNU libc on my Linux system by linking against
60 to libc.so which comes with glibc all I get is a core dump.''
62 [Q17] ``Looking through the shared libc file I haven't found the
63 functions `stat', `lstat', `fstat', and `mknod' and while
64 linking on my Linux system I get error messages. How is
65 this supposed to work?''
67 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
68 [Q1] ``What systems does the GNU C Library run on?''
70 [A1] {UD} This is difficult to answer. The file `README' lists the
71 architectures GNU libc is known to run *at some time*. This does not
72 mean that it still can be compiled and run on them in the moment.
74 The systems glibc is known to work on in the moment and most probably
78 i[3456]86-*-linux Linux-2.0 on Intel
79 m68k-*-linux Linux-2.0 on Motorola 680x0
80 alpha-*-linux Linux-2.0 on DEC Alpha
82 Other Linux platforms are also on the way to be supported but I need
83 some success reports first.
85 If you have a system not listed above (or in the `README' file) and
86 you are really interested in porting it, contact
88 <bug-glibc@prep.ai.mit.edu>
91 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
92 [Q2] ``What compiler do I need to build GNU libc?''
94 [A2] {UD} It is (almost) impossible to compile GNU C Library using a
95 different compiler than GNU CC. A lot of extensions of GNU CC are
96 used to increase the portability and speed.
98 But this does not mean you have to use GNU CC for using the GNU C
99 Library. In fact you should be able to use the native C compiler
100 because the success only depends on the binutils: the linker and
103 The GNU CC is found like all other GNU packages on
104 ftp://prep.ai.mit.edu/pub/gnu
105 or better one of the many mirror sites.
107 You always should try to use the latest official release. Older
108 versions might not have all the features GNU libc could use.
111 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
112 [Q3] ``When starting `make' I get only errors messages.
115 [A3] {UD} You definitely need GNU make to translate GNU libc. No
116 other make program has the needed functionality.
118 Versions before 3.74 have bugs which prevent correct execution so you
119 should upgrade to the latest version before starting the compilation.
122 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
123 [Q4] ``After I changed configure.in I get `Autoconf version X.Y.
124 or higher is required for this script'. What can I do?''
126 [A4] {UD} You have to get the specified autoconf version (or a later)
127 from your favourite mirror of prep.ai.mit.edu.
130 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
131 [Q5] ``Do I need a special linker or archiver?''
133 [A5] {UD} If your native versions are not too buggy you can probably
134 work with them. But GNU libc works best with GNU binutils.
136 On systems where the native linker does not support weak symbols you
137 will not get a really ISO C compliant C library. Generally speaking
138 you should use the GNU binutils if they provide at least the same
139 functionality as your system's tools.
141 Always get the newest release of GNU binutils available.
142 Older releases are known to have bugs that affect building the GNU C
146 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
147 [Q6] ``Do I need some more things to compile GNU C Library?''
149 [A6] {UD} Yes, there are some more :-).
151 * GNU gettext; the GNU libc is internationalized and partly localized.
152 For bringing the messages for the different languages in the needed
153 form the tools from the GNU gettext package are necessary. See
154 ftp://prep.ai.mit.edu/pub/gnu or better any mirror site.
156 * lots of diskspace (for i?86-linux this means, e.g., ~70MB).
158 You should avoid compiling on a NFS mounted device. This is very
161 * plenty of time (approx 1h for i?86-linux on i586@133 or 2.5h on
162 i486@66 or 4.5h on i486@33).
164 If you have some more measurements let me know.
166 * Some files depend on special tools. E.g., files ending in .gperf
167 need a `gperf' program. The GNU version (part of libg++) is known
168 to work while some vendor versions do not.
170 * When compiling for Linux:
172 + the header files of the Linux kernel must be available in the
173 search path of the CPP as <linux/*.h> and <asm/*.h>.
175 * Some files depend on special tools. E.g., files ending in .gperf
176 need a `gperf' program. The GNU version (part of libg++) is known
177 to work while some vendor versions do not.
179 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
180 [Q7] ``When I run `nm -u libc.so' on the produced library I still
181 find unresolved symbols? Can this be ok?''
183 [A7] {UD} Yes, this is ok. There can be several kinds of unresolved
186 * magic symbols automatically generated by the linker. Names are
187 often like __start_* and __stop_*
189 * symbols starting with _dl_* come from the dynamic linker
191 * symbols resolved by using libgcc.a
192 (__udivdi3, __umoddi3, or similar)
194 * weak symbols, which need not be resolved at all
195 (currently fabs among others; this gets resolved if the program
196 is linked against libm, too.)
198 Generally, you should make sure you find a real program which produces
199 errors while linking before deciding there is a problem.
202 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
203 [Q8] ``Can I replace the libc on my Linux system with GNU libc?''
205 [A8] {UD} You cannot replace any existing libc for Linux with GNU
206 libc. There are different versions of C libraries and you can run
207 libcs with different major version independently.
209 For Linux there are today two libc versions:
210 libc-4 old a.out libc
211 libc-5 current ELF libc
213 GNU libc will have the major number 6 and therefore you can have this
214 additionally installed. For more information consult documentation for
215 shared library handling. The Makefiles of GNU libc will automatically
216 generate the needed symbolic links which the linker will use.
219 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
220 [Q9] ``I expect GNU libc to be 100% source code compatible with
221 the old Linux based GNU libc. Why isn't it like this?''
223 [A9] {DMT,UD} Not every extension in Linux libc's history was well
224 thought-out. In fact it had a lot of problems with standards compliance
225 and with cleanliness. With the introduction of a new version number these
226 errors now can be corrected. Here is a list of the known source code
229 * _GNU_SOURCE: glibc does not automatically define _GNU_SOURCE. Thus,
230 if a program depends on GNU extensions or some other non-standard
231 functionality, it is necessary to compile it with C compiler option
232 -D_GNU_SOURCE, or better, to put `#define _GNU_SOURCE' at the beginning
233 of your source files, before any C library header files are included.
234 This difference normally manifests itself in the form of missing
235 prototypes and/or data type definitions. Thus, if you get such errors,
236 the first thing you should do is try defining _GNU_SOURCE and see if
237 that makes the problem go away.
239 For more information consult the file `NOTES' part of the GNU C
242 * reboot(): GNU libc sanitizes the interface of reboot() to be more
243 compatible with the interface used on other OSes. In particular,
244 reboot() as implemented in glibc takes just one argument. This argument
245 corresponds to the third argument of the Linux reboot system call.
246 That is, a call of the form reboot(a, b, c) needs to be changed into
248 Beside this the header <sys/reboot.h> defines the needed constants
249 for the argument. These RB_* constants should be used instead of the
250 cryptic magic numbers.
252 * swapon(): the interface of this function didn't changed, but the
253 prototype is in a separate header file <sys/swap.h>. For the additional
254 argument of of swapon() you should use the SWAP_* constants from
255 <linux/swap.h>, which get defined when <sys/swap.h> is included.
257 * errno: If a program uses variable "errno", then it _must_ include header
258 file <errno.h>. The old libc often (erroneously) declared this variable
259 implicitly as a side-effect of including other libc header files. glibc
260 is careful to avoid such namespace pollution, which, in turn, means that
261 you really need to include the header files that you depend on. This
262 difference normally manifests itself in the form of the compiler
263 complaining about the references of the undeclared symbol "errno".
265 * Linux-specific syscalls: All Linux system calls now have appropriate
266 library wrappers and corresponding declarations in various header files.
267 This is because the syscall() macro that was traditionally used to
268 work around missing syscall wrappers are inherently non-portable and
269 error-prone. The following tables lists all the new syscall stubs,
270 the header-file declaring their interface and the system call name.
272 syscall name: wrapper name: declaring header file:
273 ------------- ------------- ----------------------
274 bdflush bdflush <sys/kdaemon.h>
275 create_module create_module <sys/module.h>
276 delete_module delete_module <sys/module.h>
277 get_kernel_syms get_kernel_syms <sys/module.h>
278 init_module init_module <sys/module.h>
279 syslog ksyslog_ctl <sys/klog.h>
281 * lpd: Older versions of lpd depend on a routine called _validuser().
282 The library does not provide this function, but instead provides
283 __ivaliduser() which has a slightly different interfaces. Simply
284 upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
285 lpd is known to be working).
287 * resolver functions/BIND: like on many other systems the functions of
288 the resolver library are not included in the libc itself. There is
289 a separate library libresolv. If you find some symbols starting with
290 `res_*' undefined simply add -lresolv to your call of the linker.
293 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
294 [Q10] ``Why does getlogin() always return NULL on my Linux box?''
296 [A10] {UD} The GNU C library has a format for the UTMP and WTMP file
297 which differs from what your system currently has. It was extended to
298 fulfill the needs of the next years when IPv6 is introduced. So the
299 record size is different, fields might have a different position and
300 so reading the files written by functions from the one library cannot
301 be read by functions from the other library. Sorry, but this is what
302 a major release is for. It's better to have a cut now than having no
303 means to support the new techniques later.
306 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
307 [Q11] ``Where are the DST_* constants found in <sys/time.h> on many
310 [A11] {UD} These constants come from the old BSD days and are not used
311 today anymore (even the Linux based glibc does not implement the handling
312 although the constants are defined).
314 Instead GNU libc contains the zone database handling and compatibility
315 code for POSIX TZ environment variable handling.
318 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
319 [Q12] ``The `gencat' utility cannot process the input which are
320 successfully used on my Linux libc based system. Why?''
322 [A12] {UD} Unlike the author of the `gencat' program which is distributed
323 with Linux libc I have read the underlying standards before writing the
324 code. It is completely compatible with the specification given in
325 X/Open Portability Guide.
327 To ease the transition from the Linux version some of the non-standard
328 features are also present in the `gencat' program of GNU libc. This
329 mainly includes the use of symbols for the message number and the automatic
330 generation of header files which contain the needed #defines to map the
333 Here is a simple SED script to convert at least some Linux specific
334 catalog files to the XPG4 form:
336 -----------------------------------------------------------------------
337 # Change catalog source in Linux specific format to standard XPG format.
338 # Ulrich Drepper <drepper@cygnus.com>, 1996.
342 s/\$ #\([^ ]*\).*/\1/
344 s/\$ #[^ ]* *\(.*\)/\$ \1/
350 s/\(.*\)\n\(.*\)/\2 \1/
352 -----------------------------------------------------------------------
355 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
356 [Q13] ``How do I configure GNU libc so that the essential libraries
357 like libc.so go into /lib and the other into /usr/lib?''
359 [A13] {UD} Like all other GNU packages GNU libc is configured to use a
360 base directory and install all files relative to this. If you intend
361 to really use GNU libc on your system this base directory is /usr. I.e.,
363 configure --prefix=/usr <other_options>
365 Some systems like Linux have a filesystem standard which makes a
366 difference between essential libraries and others. Essential
367 libraries are placed in /lib because this directory is required to be
368 located on the same disk partition as /. The /usr subtree might be
369 found on another partition/disk.
371 To install the essential libraries which come with GNU libc in /lib
372 one must explicitly tell this. Autoconf has no option for this so you
373 have to use the file where all user supplied additional information
374 should go in: `configparms' (see the `INSTALL' file). For Linux the
375 `configparms' file should contain:
380 The first line specifies the directory for the essential libraries,
381 the second line the directory for file which are by tradition placed
382 in a directory named /etc.
385 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
386 [Q14] ``When linking with the new libc I get unresolved symbols
387 `crypt' and `setkey'. Why aren't these functions in the
390 [A14] {UD} Remember the US restrictions of exporting cryptographic
391 programs and source code. Until this law gets abolished we cannot
392 ship the cryptographic function together with the libc.
394 But of course we provide the code and there is an very easy way to use
395 this code. First get the extra package. People in the US way get it
396 from the same place they got the GNU libc from. People outside the US
397 should get the code from ftp.uni-c.dk [129.142.6.74], or another
398 archive site outside the USA. The README explains how to install the
401 If you already have the crypt code on your system the reason for the
402 failure is probably that you failed to link with -lcrypt. The crypto
403 functions are in a separate library to make it possible to export GNU
404 libc binaries from the US.
407 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
408 [Q15] ``What are these `add-ons'?''
410 [A15] {UD} To avoid complications with external or external source
411 code some optional parts of the libc are distributed as separate
412 packages (e.g., the crypt package, see Q14).
414 To ease the use as part of GNU libc the installer just has to unpack
415 the package and tell the configuration script about these additional
416 subdirectories using the --enable-add-ons option. When you add the
417 crypt add-on you just have to use
419 configure --enable-add-ons=crypt,XXX ...
421 where XXX are possible other add-ons and ... means the rest of the
424 You can use add-ons also to overwrite some files in glibc. The add-on
425 system dependent subdirs are search first. It is also possible to add
426 banner files (use a file named `Banner') or create shared libraries.
428 Using add-ons has the big advantage that the makefiles of the GNU libc
429 can be used. Only some few stub rules must be written to get
430 everything running. Even handling of architecture dependent
431 compilation is provided. The GNU libc's sysdeps/ directory shows how
435 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
436 [Q16] ``When I use GNU libc on my Linux system by linking against
437 to libc.so which comes with glibc all I get is a core dump.''
439 [A16] {UD} It is not enough to simply link against the GNU libc
440 library itself. The GNU C library comes with its own dynamic linker
441 which really conforms to the ELF API standard. This dynamic linker
444 Normally this is done by the compiler. The gcc will use
446 -dynamic-linker /lib/ld-linux.so.1
448 unless the user specifies her/himself a -dynamic-linker argument. But
449 this is not the correct name for the GNU dynamic linker. The correct
450 name is /lib/ld.so.1 which is the name specified in the SVr4 ABi.
452 To change your environment to use GNU libc for compiling you need to
453 change the `specs' file of your gcc. This file is normally found at
455 /usr/lib/gcc-lib/<arch>/<version>/specs
457 In this file you have to change a few things:
459 - change `ld-linux.so.1' to `ld.so.1'
461 - remove all expression `%{...:-lgmon}'; there is no libgmon in glibc
464 Things are getting a bit more complicated if you have GNU libc
465 installed in some other place than /usr, i.e., if you do not want to
466 use it instead of the old libc. In this case the needed startup files
467 and libraries are not found in the regular places. So the specs file
468 must tell the compiler and linker exactly what to use. Here is for
469 example the gcc-2.7.2 specs file when GNU libc is installed at
472 -----------------------------------------------------------------------
474 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
480 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} -I/home/gnu/include
489 %{!shared:crtend.o%s} %{shared:crtendS.o%s} /home/gnu/lib/crtn.o%s
492 -m elf_i386 -rpath=/home/gnu/lib -L/home/gnu/lib %{shared:-shared} %{!shared: %{!ibcs: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker=/home/gnu/lib/ld.so.1}} %{static:-static}}}
495 %{!shared: %{mieee-fp:-lieee} %{p:-lc_p} %{!p:%{pg:-lc_p} %{!pg:-lc}}}
501 %{!shared: %{pg:/home/gnu/lib/gcrt1.o%s} %{!pg:%{p:/home/gnu/lib/gcrt1.o} %{!p:/home/gnu/lib/crt1.o%s}}} /home/gnu/lib/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
503 *switches_need_spaces:
507 %{funsigned-char:-D__CHAR_UNSIGNED__}
510 -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
518 -----------------------------------------------------------------------
520 Future versions of GCC will automatically provide the correct specs.
523 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
524 [Q17] ``Looking through the shared libc file I haven't found the
525 functions `stat', `lstat', `fstat', and `mknod' and while
526 linking on my Linux system I get error messages. How is
527 this supposed to work?''
529 [A17] {RM} Believe it or not, stat and lstat (and fstat, and mknod)
530 are supposed to be undefined references in libc.so.6! Your problem is
531 probably a missing or incorrect /usr/lib/libc.so file; note that this
532 is a small text file now, not a symlink to libc.so.6. It should look
535 GROUP ( libc.so.6 ld.so.1 libc.a )
538 {UD} The Linux ldconfig file probably generates a link libc.so ->
539 libc.so.6 in /lib. This is not correct. There must not be such a
540 link. The linker script with the above contents is placed in
541 /usr/lib which is enough for the linker.
544 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
546 Answers were given by:
547 {UD} Ulrich Drepper, <drepper@cygnus.com>
548 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
549 {RM} Roland McGrath, <roland@gnu.ai.mit.edu>