1 Frequently Asked Questions about the GNU C Library
3 This document tries to answer questions a user might have when
4 installing and using glibc. Please make sure you read this before
5 sending questions or bug reports to the maintainers.
7 The GNU C library is very complex. The installation process has not
8 been completely automated; there are too many variables. You can do
9 substantial damage to your system by installing the library
10 incorrectly. Make sure you understand what you are undertaking before
13 If you have any questions you think should be answered in this document,
20 ?? What systems does the GNU C Library run on?
22 {UD} This is difficult to answer. The file `README' lists the
23 architectures GNU libc was known to run on *at some time*. This does
24 not mean that it still can be compiled and run on them now.
26 The systems glibc is known to work on as of this release, and most
27 probably in the future, are:
30 i[3456]86-*-linux-gnu Linux-2.x on Intel
31 m68k-*-linux-gnu Linux-2.x on Motorola 680x0
32 alpha-*-linux-gnu Linux-2.x on DEC Alpha
33 powerpc-*-linux-gnu Linux and MkLinux on PowerPC systems
34 sparc-*-linux-gnu Linux-2.x on SPARC
35 sparc64-*-linux-gnu Linux-2.x on UltraSPARC
37 Ports to other Linux platforms are in development, and may in fact
38 work already, but no one has sent us success reports for them.
39 Currently no ports to other operating systems are underway, although a
40 few people have expressed interest.
42 If you have a system not listed above (or in the `README' file) and
43 you are really interested in porting it, contact
47 ?? What compiler do I need to build GNU libc?
49 {UD} You must use GNU CC to compile GNU libc. A lot of extensions of
50 GNU CC are used to increase portability and speed.
52 GNU CC is found, like all other GNU packages, on
53 ftp://prep.ai.mit.edu/pub/gnu
54 and the many mirror sites. prep is always overloaded, so try to find
57 You always should try to use the latest official release. Older
58 versions may not have all the features GNU libc requires. On most
59 supported platforms (for powerpc see question ?powerpc), 2.7.2.3 is
60 the earliest version that works at all.
62 ?? When I try to compile glibc I get only error messages.
65 {UD} You definitely need GNU make to translate GNU libc. No
66 other make program has the needed functionality.
68 We recommend version GNU make version 3.75. Versions 3.76 and 3.76.1
69 have bugs which appear when building big projects like GNU libc.
70 Versions before 3.74 have bugs and/or are missing features.
72 ?? Do I need a special linker or archiver?
74 {UD} You may be able to use your system linker, but GNU libc works
75 best with GNU binutils.
77 On systems where the native linker does not support weak symbols you
78 will not get a fully ISO C compliant C library. Generally speaking
79 you should use the GNU binutils if they provide at least the same
80 functionality as your system's tools.
82 Always get the newest release of GNU binutils available. Older
83 releases are known to have bugs that prevent a successful compilation.
85 {ZW} As of release 2.1 a linker supporting symbol versions is
86 required. For Linux, get binutils-2.8.1.0.17 or later. Other systems
87 may have native linker support, but it's moot right now, because glibc
88 has not been ported to them.
90 ??powerpc What tools do I need for powerpc?
92 {GK} For a successful installation you definitely need the most recent
93 tools. You can safely assume that anything earlier than binutils
94 2.8.1.0.17 and egcs-1.0 will have problems. We'd advise at the moment
95 binutils 2.8.1.0.18 and egcs-1.0.1.
97 In fact, egcs 1.0.1 currently has two serious bugs that prevent a
98 clean make; one relates to switch statement folding, for which there
99 is a temporary patch at
101 <http://discus.anu.edu.au/~geoffk/egcs-1.0-geoffk.diff.gz>
103 and the other relates to 'forbidden register spilled', for which the
106 CFLAGS-condvar.c += -fno-inline
108 in configparms. Later versions of egcs may fix these problems.
111 ?? Do I need some more things to compile GNU C Library?
113 {UD} Yes, there are some more :-).
115 * GNU gettext. This package contains the tools needed to construct
116 `message catalog' files containing translated versions of system
117 messages. See ftp://prep.ai.mit.edu/pub/gnu or better any mirror
118 site. (We distribute compiled message catalogs, but they may not be
121 * Some files depend on special tools. E.g., files ending in .gperf
122 need a `gperf' program. The GNU version (part of libg++) is known
123 to work while some vendor versions do not.
125 You should not need these tools unless you change the source files.
127 * Some scripts need perl5 - but at the moment those scripts are not
128 vital for building and installing GNU libc (some data files will not
131 * When compiling for Linux, the header files of the Linux kernel must
132 be available to the compiler as <linux/*.h> and <asm/*.h>.
134 * lots of disk space (~170MB for i?86-linux; more for RISC platforms).
136 * plenty of time. Compiling just the shared and static libraries for
137 i?86-linux takes approximately 1h on an i586@133, or 2.5h on
138 i486@66, or 4.5h on i486@33. Multiply this by 1.5 or 2.0 if you
139 build profiling and/or the highly optimized version as well. For
140 Hurd systems times are much higher.
142 You should avoid compiling in a NFS mounted filesystem. This is
145 James Troup <J.J.Troup@comp.brad.ac.uk> reports a compile time of
146 45h34m for a full build (shared, static, and profiled) on Atari
147 Falcon (Motorola 68030 @ 16 Mhz, 14 Mb memory) and Jan Barte
148 <yann@plato.uni-paderborn.de> reports 22h48m on Atari TT030
149 (Motorola 68030 @ 32 Mhz, 34 Mb memory)
151 If you have some more measurements let me know.
153 ?? When I run `nm -u libc.so' on the produced library I still
154 find unresolved symbols. Can this be ok?
156 {UD} Yes, this is ok. There can be several kinds of unresolved
159 * magic symbols automatically generated by the linker. These have names
160 like __start_* and __stop_*
162 * symbols starting with _dl_* come from the dynamic linker
164 * symbols resolved by using libgcc.a
165 (__udivdi3, __umoddi3, or similar)
167 * weak symbols, which need not be resolved at all (fabs for example)
169 Generally, you should make sure you find a real program which produces
170 errors while linking before deciding there is a problem.
172 ??addon What are these `add-ons'?
174 {UD} To avoid complications with export rules or external source
175 code some optional parts of the libc are distributed as separate
176 packages (e.g., the crypt package, see ?crypt).
178 To use these packages as part of GNU libc, just unpack the tarfiles in
179 the libc source directory and tell the configuration script about them
180 using the --enable-add-ons option. If you give just --enable-add-ons
181 configure tries to find all the add-on packages in your source tree.
182 This may not work. If it doesn't, or if you want to select only a
183 subset of the add-ons, give a comma-separated list of the add-ons to
186 configure --enable-add-ons=crypt,linuxthreads
190 Add-ons can add features (including entirely new shared libraries),
191 override files, provide support for additional architectures, and
192 just about anything else. The existing makefiles do most of the work;
193 only some few stub rules must be written to get everything running.
195 ?? My XXX kernel emulates a floating-point coprocessor for me.
196 Should I enable --with-fp?
198 {ZW} An emulated FPU is just as good as a real one, as far as the C
199 library is concerned. You only need to say --without-fp if your
200 machine has no way to execute floating-point instructions.
202 People who are interested in squeezing the last drop of performance
203 out of their machine may wish to avoid the trap overhead, but this is
204 far more trouble than it's worth: you then have to compile
205 *everything* this way, including the compiler's internal libraries
206 (libgcc.a for GNU C), because the calling conventions change.
208 ?? When compiling GNU libc I get lots of errors saying functions
209 in glibc are duplicated in libgcc.
211 {EY} This is *exactly* the same problem that I was having. The
212 problem was due to the fact that configure didn't correctly detect
213 that the linker flag --no-whole-archive was supported in my linker.
214 In my case it was because I had run ./configure with bogus CFLAGS, and
217 One thing that is particularly annoying about this problem is that
218 once this is misdetected, running configure again won't fix it unless
219 you first delete config.cache.
221 {UD} Starting with glibc-2.0.3 there should be a better test to avoid
222 some problems of this kind. The setting of CFLAGS is checked at the
223 very beginning and if it is not usable `configure' will bark.
225 ?? Why do I get messages about missing thread functions when I use
226 the librt? I don't even use threads.
228 {UD} In this case you probably mixed up your installation of the libc.
229 The librt internally uses threads and it has implicit references to
230 the thread library. Normally these references are satisfied
231 automatically but if the thread library belonging to the librt is not
232 in the expected place one has to specify this place. When using GNU
233 ld it works like this:
235 gcc -o foo foo.c -Wl,-rpath-link=/some/other/dir -lrt
237 The `/some/other/dir' should contain the matching thread library and
238 `ld' will use the given path to find the implicitly referenced library
239 while not disturbing any other link path order.
241 ?? What's the problem with configure --enable-omitfp?
243 {AJ} When --enable-omitfp is set the libraries are built without frame
244 pointers. Some compilers produce buggy code for this model and
245 therefore we don't advise using it at the moment.
247 If you use --enable-omitfp, you're on your own. If you encounter
248 problems with a library that was build this way, we advise you to
249 rebuild the library without --enable-omitfp. If the problem vanishes
250 consider tracking the problem down and report it as compiler failure.
252 Since a library build with --enable-omitfp is undebuggable on most
253 systems, debuggable libraries are also built - you can use it by
254 appending "_g" to the library names.
256 The compilation of these extra libraries and the compiler optimizations
257 slow down the build process and need more disk space.
259 ? Installation and configuration issues
261 ?? Can I replace the libc on my Linux system with GNU libc?
263 {UD} You cannot replace any existing libc for Linux with GNU
264 libc. It is binary incompatible and therefore has a different major
265 version. You can, however, install it alongside your existing libc.
267 For Linux there are three major libc versions:
269 libc-5 original ELF libc
272 You can have any combination of these three installed. For more
273 information consult documentation for shared library handling. The
274 Makefiles of GNU libc will automatically generate the needed symbolic
275 links which the linker will use.
277 ?? How do I configure GNU libc so that the essential libraries
278 like libc.so go into /lib and the other into /usr/lib?
280 {UD,AJ} Like all other GNU packages GNU libc is designed to use a base
281 directory and install all files relative to this. The default is
282 /usr/local, because this is safe (it will not damage the system if
283 installed there). If you wish to install GNU libc as the primary C
284 library on your system, set the base directory to /usr (i.e. run
285 configure --prefix=/usr <other_options>). Note that this can damage
286 your system; see ?safety for details.
288 Some systems like Linux have a filesystem standard which makes a
289 difference between essential libraries and others. Essential
290 libraries are placed in /lib because this directory is required to be
291 located on the same disk partition as /. The /usr subtree might be
292 found on another partition/disk. If you configure for Linux with
293 --prefix=/usr, then this will be done automatically.
295 To install the essential libraries which come with GNU libc in /lib on
296 systems other than Linux one must explicitly request it. Autoconf has
297 no option for this so you have to use a `configparms' file (see the
298 `INSTALL' file for details). It should contain:
303 The first line specifies the directory for the essential libraries,
304 the second line the directory for system configuration files.
306 ??safety How should I avoid damaging my system when I install GNU libc?
308 {ZW} If you wish to be cautious, do not configure with --prefix=/usr.
309 If you don't specify a prefix, glibc will be installed in /usr/local,
310 where it will probably not break anything. (If you wish to be
311 certain, set the prefix to something like /usr/local/glibc2 which is
312 not used for anything.)
314 The dangers when installing glibc in /usr are twofold:
316 * glibc will overwrite the headers in /usr/include. Other C libraries
317 install a different but overlapping set of headers there, so the
318 effect will probably be that you can't compile anything. You need to
319 rename /usr/include out of the way first. (Do not throw it away; you
320 will then lose the ability to compile programs against your old libc.)
322 * None of your old libraries, static or shared, can be used with a
323 different C library major version. For shared libraries this is not a
324 problem, because the filenames are different and the dynamic linker
325 will enforce the restriction. But static libraries have no version
326 information. You have to evacuate all the static libraries in
327 /usr/lib to a safe location.
329 The situation is rather similar to the move from a.out to ELF which
330 long-time Linux users will remember.
332 ?? Do I need to use GNU CC to compile programs that will use the
335 {ZW} In theory, no; the linker does not care, and the headers are
336 supposed to check for GNU CC before using its extensions to the C
339 However, there are currently no ports of glibc to systems where
340 another compiler is the default, so no one has tested the headers
341 extensively against another compiler. You may therefore encounter
342 difficulties. If you do, please report them as bugs.
344 Also, in several places GNU extensions provide large benefits in code
345 quality. For example, the library has hand-optimized, inline assembly
346 versions of some string functions. These can only be used with GCC.
347 See ?string for details.
349 ??crypt When linking with the new libc I get unresolved symbols
350 `crypt' and `setkey'. Why aren't these functions in the
353 {UD} The US places restrictions on exporting cryptographic programs
354 and source code. Until this law gets abolished we cannot ship the
355 cryptographic functions together with glibc.
357 The functions are available, as an add-on (see ?addon). People in the
358 US may get it from the same place they got GNU libc from. People
359 outside the US should get the code from ftp://ftp.ifi.uio.no/pub/gnu,
360 or another archive site outside the USA. The README explains how to
363 If you already have the crypt code on your system the reason for the
364 failure is probably that you did not link with -lcrypt. The crypto
365 functions are in a separate library to make it possible to export GNU
366 libc binaries from the US.
368 ?? When I use GNU libc on my Linux system by linking against
369 the libc.so which comes with glibc all I get is a core dump.
371 {UD} On Linux, gcc sets the dynamic linker to /lib/ld-linux.so.1
372 unless the user specifies a -dynamic-linker argument. This is the
373 name of the libc5 dynamic linker, which does not work with glibc.
375 For casual use of GNU libc you can just specify
376 -dynamic-linker=/lib/ld-linux.so.2
378 which is the glibc dynamic linker, on Linux systems. On other systems
379 the name is /lib/ld.so.1.
381 To change your environment to use GNU libc for compiling you need to
382 change the `specs' file of your gcc. This file is normally found at
384 /usr/lib/gcc-lib/<arch>/<version>/specs
386 In this file you have to change a few things:
388 - change `ld-linux.so.1' to `ld-linux.so.2'
390 - remove all expression `%{...:-lgmon}'; there is no libgmon in glibc
392 - fix a minor bug by changing %{pipe:-} to %|
394 Here is what the gcc-2.7.2 specs file should look like when GNU libc
395 is installed at /usr:
397 -----------------------------------------------------------------------
399 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
405 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
414 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
417 -m elf_i386 %{shared:-shared} %{!shared: %{!ibcs: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} %{static:-static}}}
420 %{!shared: %{pthread:-lpthread} %{profile:-lc_p} %{!profile: -lc}}
426 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
428 *switches_need_spaces:
432 %{funsigned-char:-D__CHAR_UNSIGNED__}
435 -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
443 -----------------------------------------------------------------------
445 Things get a bit more complicated if you have GNU libc installed in
446 some other place than /usr, i.e., if you do not want to use it instead
447 of the old libc. In this case the needed startup files and libraries
448 are not found in the regular places. So the specs file must tell the
449 compiler and linker exactly what to use.
451 Version 2.7.2.3 does and future versions of GCC will automatically
452 provide the correct specs.
454 ?? Looking through the shared libc file I haven't found the
455 functions `stat', `lstat', `fstat', and `mknod' and while
456 linking on my Linux system I get error messages. How is
457 this supposed to work?
459 {RM} Believe it or not, stat and lstat (and fstat, and mknod)
460 are supposed to be undefined references in libc.so.6! Your problem is
461 probably a missing or incorrect /usr/lib/libc.so file; note that this
462 is a small text file now, not a symlink to libc.so.6. It should look
465 GROUP ( libc.so.6 ld.so.1 libc.a )
467 or in ix86/Linux and alpha/Linux:
469 GROUP ( libc.so.6 ld-linux.so.2 libc.a )
471 ?? How can I compile gcc 2.7.2.1 from the gcc source code using
474 {AJ} There's only correct support for glibc 2.0.x in gcc 2.7.2.3
475 or later. You should get at least gcc 2.7.2.3. All previous versions
476 had problems with glibc support.
478 ?? The `gencat' utility cannot process the catalog sources which
479 were used on my Linux libc5 based system. Why?
481 {UD} The `gencat' utility provided with glibc complies to the XPG
482 standard. The older Linux version did not obey the standard, so they
485 To ease the transition from the Linux version some of the non-standard
486 features are also present in the `gencat' program of GNU libc. This
487 mainly includes the use of symbols for the message number and the automatic
488 generation of header files which contain the needed #defines to map the
491 Here is a simple SED script to convert at least some Linux specific
492 catalog files to the XPG4 form:
494 -----------------------------------------------------------------------
495 # Change catalog source in Linux specific format to standard XPG format.
496 # Ulrich Drepper <drepper@cygnus.com>, 1996.
500 s/\$ #\([^ ]*\).*/\1/
502 s/\$ #[^ ]* *\(.*\)/\$ \1/
508 s/\(.*\)\n\(.*\)/\2 \1/
510 -----------------------------------------------------------------------
512 ?? I have set up /etc/nis.conf, and the Linux libc 5 with NYS
513 works great. But the glibc NIS+ doesn't seem to work.
515 {TK} The glibc NIS+ implementation uses a /var/nis/NIS_COLD_START
516 file for storing information about the NIS+ server and their public
517 keys, because the nis.conf file does not contain all the necessary
518 information. You have to copy a NIS_COLD_START file from a Solaris
519 client (the NIS_COLD_START file is byte order independent) or generate
520 it with nisinit from the nis-tools package (available at
521 http://www-vt.uni-paderborn.de/~kukuk/linux/nisplus.html).
523 ?? After installing glibc name resolving doesn't work properly.
525 {AJ} You probably should read the manual section describing
526 nsswitch.conf (just type `info libc "NSS Configuration File"').
527 The NSS configuration file is usually the culprit.
529 ?? I have /usr/include/net and /usr/include/scsi as symlinks
530 into my Linux source tree. Is that wrong?
532 {PB} This was necessary for libc5, but is not correct when using
533 glibc. Including the kernel header files directly in user programs
534 usually does not work (see ?kerhdr). glibc provides its own <net/*>
535 and <scsi/*> header files to replace them, and you may have to remove
536 any symlink that you have in place before you install glibc. However,
537 /usr/include/asm and /usr/include/linux should remain as they were.
539 ?? Programs like `logname', `top', `uptime' `users', `w' and
540 `who', show incorrect information about the (number of)
541 users on my system. Why?
545 ?? After upgrading to glibc 2.1 with symbol versioning I get
546 errors about undefined symbols. What went wrong?
548 {AJ} The problem is caused either by wrong program code or tools. In
549 the versioned libc a lot of symbols are now local that were global
550 symbols in previous versions. It seems that programs linked against
551 older versions often accidentally used libc global variables --
552 something that should not happen.
554 The only way to fix this is to recompile your program. Sorry, that's
555 the price you might have to pay once for quite a number of advantages
556 with symbol versioning.
558 ?? When I start the program XXX after upgrading the library
560 XXX: Symbol `_sys_errlist' has different size in shared
561 object, consider re-linking
562 Why? What should I do?
564 {UD} As the message says, relink the binary. The problem is that
565 a few symbols from the library can change in size and there is no way
566 to avoid this. _sys_errlist is a good example. Occasionally there are
567 new error numbers added to the kernel and this must be reflected at user
568 level, breaking programs that refer to them directly.
570 Such symbols should normally not be used at all. There are mechanisms
571 to avoid using them. In the case of _sys_errlist, there is the
572 strerror() function which should _always_ be used instead. So the
573 correct fix is to rewrite that part of the application.
575 In some situations (especially when testing a new library release) it
576 might be possible that a symbol changed size when that should not have
577 happened. So in case of doubt report such a warning message as a
580 ? Source and binary incompatibilities, and what to do about them
582 ?? I expect GNU libc to be 100% source code compatible with
583 the old Linux based GNU libc. Why isn't it like this?
585 {DMT,UD} Not every extension in Linux libc's history was well
586 thought-out. In fact it had a lot of problems with standards compliance
587 and with cleanliness. With the introduction of a new version number these
588 errors can now be corrected. Here is a list of the known source code
591 * _GNU_SOURCE: glibc does not make the GNU extensions available
592 automatically. If a program depends on GNU extensions or some
593 other non-standard functionality, it is necessary to compile it
594 with the C compiler option -D_GNU_SOURCE, or better, to put
595 `#define _GNU_SOURCE' at the beginning of your source files, before
596 any C library header files are included. This difference normally
597 manifests itself in the form of missing prototypes and/or data type
598 definitions. Thus, if you get such errors, the first thing you
599 should do is try defining _GNU_SOURCE and see if that makes the
602 For more information consult the file `NOTES' in the GNU C library
605 * reboot(): GNU libc sanitizes the interface of reboot() to be more
606 compatible with the interface used on other OSes. reboot() as
607 implemented in glibc takes just one argument. This argument
608 corresponds to the third argument of the Linux reboot system call.
609 That is, a call of the form reboot(a, b, c) needs to be changed into
610 reboot(c). Beside this the header <sys/reboot.h> defines the needed
611 constants for the argument. These RB_* constants should be used
612 instead of the cryptic magic numbers.
614 * swapon(): the interface of this function didn't change, but the
615 prototype is in a separate header file <sys/swap.h>. This header
616 file also provides the SWAP_* constants defined by <linux/swap.h>;
617 you should use them for the second argument to swapon().
619 * errno: If a program uses the variable "errno", then it _must_
620 include <errno.h>. The old libc often (erroneously) declared this
621 variable implicitly as a side-effect of including other libc header
622 files. glibc is careful to avoid such namespace pollution, which,
623 in turn, means that you really need to include the header files that
624 you depend on. This difference normally manifests itself in the
625 form of the compiler complaining about references to an undeclared
628 * Linux-specific syscalls: All Linux system calls now have appropriate
629 library wrappers and corresponding declarations in various header files.
630 This is because the syscall() macro that was traditionally used to
631 work around missing syscall wrappers are inherently non-portable and
632 error-prone. The following table lists all the new syscall stubs,
633 the header-file declaring their interface and the system call name.
635 syscall name: wrapper name: declaring header file:
636 ------------- ------------- ----------------------
637 bdflush bdflush <sys/kdaemon.h>
638 syslog ksyslog_ctl <sys/klog.h>
640 * lpd: Older versions of lpd depend on a routine called _validuser().
641 The library does not provide this function, but instead provides
642 __ivaliduser() which has a slightly different interface. Simply
643 upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
644 lpd is known to be working).
646 * resolver functions/BIND: like on many other systems the functions of
647 the resolver library are not included in libc itself. There is a
648 separate library libresolv. If you get undefined symbol errors for
649 symbols starting with `res_*' simply add -lresolv to your linker
652 * the `signal' function's behavior corresponds to the BSD semantic and
653 not the SysV semantic as it was in libc-5. The interface on all GNU
654 systems shall be the same and BSD is the semantic of choice. To use
655 the SysV behavior simply use `sysv_signal', or define _XOPEN_SOURCE.
656 See ?signal for details.
658 ??getlog Why does getlogin() always return NULL on my Linux box?
660 {UD} The GNU C library has a format for the UTMP and WTMP file which
661 differs from what your system currently has. It was extended to
662 fulfill the needs of the next years when IPv6 is introduced. The
663 record size is different and some fields have different positions.
664 The files written by functions from the one library cannot be read by
665 functions from the other library. Sorry, but this is what a major
666 release is for. It's better to have a cut now than having no means to
667 support the new techniques later.
669 {MK} There is however a (partial) solution for this problem. Please
670 take a look at the file `login/README.utmpd'.
672 ?? Where are the DST_* constants found in <sys/time.h> on many
675 {UD} These constants come from the old BSD days and are not used
676 anymore (libc5 does not actually implement the handling although the
677 constants are defined).
679 Instead GNU libc contains zone database support and compatibility code
680 for POSIX TZ environment variable handling.
682 ?? The prototypes for `connect', `accept', `getsockopt',
683 `setsockopt', `getsockname', `getpeername', `send',
684 `sendto', and `recvfrom' are different in GNU libc from
685 any other system I saw. This is a bug, isn't it?
687 {UD} No, this is no bug. This version of GNU libc already follows the
688 new Single Unix specifications (and I think the POSIX.1g draft which
689 adopted the solution). The type for a parameter describing a size is
690 now `socklen_t', a new type.
692 ??kerhdr On Linux I've got problems with the declarations in Linux
695 {UD,AJ} On Linux, the use of kernel headers is reduced to the minimum.
696 This gives Linus the ability to change the headers more freely. Also,
697 user programs are now insulated from changes in the size of kernel
700 For example, the sigset_t type is 32 or 64 bits wide in the kernel.
701 In glibc it is 1024 bits wide. This guarantees that when the kernel
702 gets a bigger sigset_t (for POSIX.1e realtime support, say) user
703 programs will not have to be recompiled. Consult the header files for
704 more information about the changes.
706 Therefore you shouldn't include Linux kernel header files directly if
707 glibc has defined a replacement. Otherwise you might get undefined
708 results because of type conflicts.
710 ?? I don't include any kernel headers myself but the compiler
711 still complains about redeclarations of types in the kernel
714 {UD} The kernel headers before Linux 2.1.61 and 2.0.32 don't work
715 correctly with glibc. Compiling C programs is possible in most cases
716 but C++ programs have (due to the change of the name lookups for
717 `struct's) problems. One prominent example is `struct fd_set'.
719 There might be some problems left but 2.1.61/2.0.32 fix most of the
720 known ones. See the BUGS file for other known problems.
722 ??signal Why don't signals interrupt system calls anymore?
724 {ZW} By default GNU libc uses the BSD semantics for signal(),
725 unlike Linux libc 5 which used System V semantics. This is partially
726 for compatibility with other systems and partially because the BSD
727 semantics tend to make programming with signals easier.
729 There are three differences:
731 * BSD-style signals that occur in the middle of a system call do not
732 affect the system call; System V signals cause the system call to
733 fail and set errno to EINTR.
735 * BSD signal handlers remain installed once triggered. System V signal
736 handlers work only once, so one must reinstall them each time.
738 * A BSD signal is blocked during the execution of its handler. In other
739 words, a handler for SIGCHLD (for example) does not need to worry about
740 being interrupted by another SIGCHLD. It may, however, be interrupted
743 There is general consensus that for `casual' programming with signals, the
744 BSD semantics are preferable. You don't need to worry about system calls
745 returning EINTR, and you don't need to worry about the race conditions
746 associated with one-shot signal handlers.
748 If you are porting an old program that relies on the old semantics, you can
749 quickly fix the problem by changing signal() to sysv_signal() throughout.
750 Alternatively, define _XOPEN_SOURCE before including <signal.h>.
752 For new programs, the sigaction() function allows you to specify precisely
753 how you want your signals to behave. All three differences listed above are
754 individually switchable on a per-signal basis with this function.
756 If all you want is for one specific signal to cause system calls to fail
757 and return EINTR (for example, to implement a timeout) you can do this with
761 ??string I've got errors compiling code that uses certain string
764 {AJ} glibc 2.1 has special string functions that are faster
765 than the normal library functions. Some of the functions are
766 implemented as inline functions and others as macros.
768 The optimized string functions are only used when compiling with
769 optimizations (-O1 or higher). The behavior can be changed with two
772 * __NO_STRING_INLINES: Don't do any string optimizations.
773 * __USE_STRING_INLINES: Use assembly language inline functions (might
774 increase code size dramatically).
776 Since some of these string functions are now additionally defined as
777 macros, code like "char *strncpy();" doesn't work anymore (and is
778 unnecessary, since <string.h> has the necessary declarations). Either
779 change your code or define __NO_STRING_INLINES.
781 {UD} Another problem in this area is that gcc still has problems on
782 machines with very few registers (e.g., ix86). The inline assembler
783 code can require almost all the registers and the register allocator
784 cannot always handle this situation.
786 One can disable the string optimizations selectively. Instead of writing
788 cp = strcpy (foo, "lkj");
792 cp = (strcpy) (foo, "lkj");
794 This disables the optimization for that specific call.
796 ?? I get compiler messages "Initializer element not constant" with
797 stdin/stdout/stderr. Why?
799 {RM,AJ} Constructs like:
800 static FILE *InPtr = stdin;
802 lead to this message. This is correct behaviour with glibc since stdin
803 is not a constant expression. Please note that a strict reading of ISO
804 C does not allow above constructs.
806 One of the advantages of this is that you can assign to stdin, stdout,
807 and stderr just like any other global variable (e.g. `stdout =
808 my_stream;'), which can be very useful with custom streams that you
809 can write with libio (but beware this is not necessarily
810 portable). The reason to implement it this way were versioning
811 problems with the size of the FILE structure.
814 ?? I can't compile with gcc -traditional (or
815 -traditional-cpp). Why?
817 {AJ} glibc2 does break -traditional and -traditonal-cpp - and will continue
818 to do so. For example constructs of the form:
822 are useful for debugging purpuses (you can use foo with your debugger
823 that's why we need the enum) and for compatibility (other systems use
824 defines and check with #ifdef).
826 ?? I get some errors with `gcc -ansi'. Isn't glibc ANSI compatible?
828 {AJ} The GNU C library is compatible with the ANSI/ISO C standard. If
829 you're using `gcc -ansi', the glibc includes which are specified in
830 the standard follow the standard. The ANSI/ISO C standard defines what
831 has to be in the include files - and also states that nothing else
832 should be in the include files (btw. you can still enable additional
833 standards with feature flags).
835 The GNU C library is conforming to ANSI/ISO C - if and only if you're
836 only using the headers and library functions defined in the standard.
840 ?? After I changed configure.in I get `Autoconf version X.Y.
841 or higher is required for this script'. What can I do?
843 {UD} You have to get the specified autoconf version (or a later one)
844 from your favorite mirror of prep.ai.mit.edu.
846 ?? When I try to compile code which uses IPv6 headers and
847 definitions on my Linux 2.x.y system I am in trouble.
848 Nothing seems to work.
850 {UD} The problem is that IPv6 development still has not reached a
851 point where the headers are stable. There are still lots of
852 incompatible changes made and the libc headers have to follow.
854 Also, make sure you have a suitably recent kernel. As of the 970401
855 snapshot, according to Philip Blundell <Philip.Blundell@pobox.com>, the
856 required kernel version is at least 2.1.30.
859 Answers were given by:
860 {UD} Ulrich Drepper, <drepper@cygnus.com>
861 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
862 {RM} Roland McGrath, <roland@gnu.org>
863 {AJ} Andreas Jaeger, <aj@arthur.rhein-neckar.de>
864 {EY} Eric Youngdale, <eric@andante.jic.com>
865 {PB} Phil Blundell, <Philip.Blundell@pobox.com>
866 {MK} Mark Kettenis, <kettenis@phys.uva.nl>
867 {ZW} Zack Weinberg, <zack@rabi.phys.columbia.edu>
868 {TK} Thorsten Kukuk, <kukuk@vt.uni-paderborn.de>
869 {GK} Geoffrey Keating, <Geoff.Keating@anu.edu.au>