(_dl_close): Fix byte count while removing the shared object from the
[glibc.git] / FAQ
blob5caf506cbc5ac8708b049e6303b459d9f1029636
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
11 you begin.
13 If you have any questions you think should be answered in this document,
14 please let me know.
16                                                   --drepper@cygnus.com
18 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
20 1. Compiling glibc
22 1.1.    What systems does the GNU C Library run on?
23 1.2.    What compiler do I need to build GNU libc?
24 1.3.    When I try to compile glibc I get only error messages.
25         What's wrong?
26 1.4.    Do I need a special linker or archiver?
27 1.5.    Do I need some more things to compile GNU C Library?
28 1.6.    When I run `nm -u libc.so' on the produced library I still
29         find unresolved symbols.  Can this be ok?
30 1.7.    What are these `add-ons'?
31 1.8.    My XXX kernel emulates a floating-point coprocessor for me.
32         Should I enable --with-fp?
33 1.9.    When compiling GNU libc I get lots of errors saying functions
34         in glibc are duplicated in libgcc.
35 1.10.   What's the problem with configure --enable-omitfp?
37 2. Installation and configuration issues
39 2.1.    Can I replace the libc on my Linux system with GNU libc?
40 2.2.    How do I configure GNU libc so that the essential libraries
41         like libc.so go into /lib and the other into /usr/lib?
42 2.3.    How should I avoid damaging my system when I install GNU libc?
43 2.4.    Do I need to use GNU CC to compile programs that will use the
44         GNU C Library?
45 2.5.    When linking with the new libc I get unresolved symbols
46         `crypt' and `setkey'.  Why aren't these functions in the
47         libc anymore?
48 2.6.    When I use GNU libc on my Linux system by linking against
49         the libc.so which comes with glibc all I get is a core dump.
50 2.7.    Looking through the shared libc file I haven't found the
51         functions `stat', `lstat', `fstat', and `mknod' and while
52         linking on my Linux system I get error messages.  How is
53         this supposed to work?
54 2.8.    How can I compile gcc 2.7.2.1 from the gcc source code using
55         glibc 2.x?
56 2.9.    The `gencat' utility cannot process the catalog sources which
57         were used on my Linux libc5 based system.  Why?
58 2.10.   I have set up /etc/nis.conf, and the Linux libc 5 with NYS
59         works great.  But the glibc NIS+ doesn't seem to work.
60 2.11.   I have killed ypbind to stop using NIS, but glibc will
61         continue using NIS.
62 2.12.   After installing glibc name resolving doesn't work properly.
63 2.13.   I have /usr/include/net and /usr/include/scsi as symlinks
64         into my Linux source tree.  Is that wrong?
65 2.14.   Programs like `logname', `top', `uptime' `users', `w' and
66         `who', show incorrect information about the (number of)
67         users on my system.  Why?
68 2.15.   When I start the program XXX after upgrading the library
69         I get
70           XXX: Symbol `_sys_errlist' has different size in shared
71           object, consider re-linking
72         Why?  What should I do?
73 2.16    What do I need for C++ development?
74 2.17    Programs using libc have their messages translated, but other
75         behavior is not localized (e.g. collating order); why?
77 3. Source and binary incompatibilities, and what to do about them
79 3.1.    I expect GNU libc to be 100% source code compatible with
80         the old Linux based GNU libc.  Why isn't it like this?
81 3.2.    Why does getlogin() always return NULL on my Linux box?
82 3.3.    Where are the DST_* constants found in <sys/time.h> on many
83         systems?
84 3.4.    The prototypes for `connect', `accept', `getsockopt',
85         `setsockopt', `getsockname', `getpeername', `send',
86         `sendto', and `recvfrom' are different in GNU libc from
87         any other system I saw.  This is a bug, isn't it?
88 3.5.    On Linux I've got problems with the declarations in Linux
89         kernel headers.
90 3.6.    I don't include any kernel headers myself but the compiler
91         still complains about redeclarations of types in the kernel
92         headers.
93 3.7.    Why don't signals interrupt system calls anymore?
95 4. Miscellaneous
97 4.1.    After I changed configure.in I get `Autoconf version X.Y.
98         or higher is required for this script'.  What can I do?
99 4.2.    When I try to compile code which uses IPv6 headers and
100         definitions on my Linux 2.x.y system I am in trouble.
101         Nothing seems to work.
104 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
106 1. Compiling glibc
108 1.1.    What systems does the GNU C Library run on?
110 {UD} This is difficult to answer.  The file `README' lists the
111 architectures GNU libc was known to run on *at some time*.  This does
112 not mean that it still can be compiled and run on them now.
114 The systems glibc is known to work on as of this release, and most
115 probably in the future, are:
117         *-*-gnu                 GNU Hurd
118         i[3456]86-*-linux-gnu   Linux-2.x on Intel
119         m68k-*-linux-gnu        Linux-2.x on Motorola 680x0
120         alpha-*-linux-gnu       Linux-2.x on DEC Alpha
122 Ports to other Linux platforms are in development, and may in fact
123 work already, but no one has sent us success reports for them.
124 Currently no ports to other operating systems are underway, although a
125 few people have expressed interest.
127 If you have a system not listed above (or in the `README' file) and
128 you are really interested in porting it, contact
130         <bug-glibc@gnu.org>
133 1.2.    What compiler do I need to build GNU libc?
135 {UD} You must use GNU CC to compile GNU libc.  A lot of extensions of
136 GNU CC are used to increase portability and speed.
138 GNU CC is found, like all other GNU packages, on
139         ftp://ftp.gnu.org/pub/gnu
140 and the many mirror sites.  ftp.gnu.org is always overloaded, so try to find
141 a local mirror first.
143 You always should try to use the latest official release.  Older
144 versions may not have all the features GNU libc requires.  On most
145 supported platforms, 2.7.2.3 is the earliest version that works at all.
148 1.3.    When I try to compile glibc I get only error messages.
149         What's wrong?
151 {UD} You definitely need GNU make to translate GNU libc.  No
152 other make program has the needed functionality.
154 We recommend version GNU make version 3.75.  Versions 3.76 and 3.76.1
155 have bugs which appear when building big projects like GNU libc.
156 Versions before 3.74 have bugs and/or are missing features.
159 1.4.    Do I need a special linker or archiver?
161 {UD} You may be able to use your system linker, but GNU libc works
162 best with GNU binutils.
164 On systems where the native linker does not support weak symbols you
165 will not get a fully ISO C compliant C library.  Generally speaking
166 you should use the GNU binutils if they provide at least the same
167 functionality as your system's tools.
169 Always get the newest release of GNU binutils available.  Older
170 releases are known to have bugs that prevent a successful compilation.
172 For alpha-linux you need at least GNU binutils 2.8.1.0.18 available from
173 ftp://ftp.yggdrasil.com/private/hjl
176 1.5.    Do I need some more things to compile GNU C Library?
178 {UD} Yes, there are some more :-).
180 * GNU gettext.  This package contains the tools needed to construct
181   `message catalog' files containing translated versions of system
182   messages. See ftp://ftp.gnu.org/pub/gnu or better any mirror
183   site.  (We distribute compiled message catalogs, but they may not be
184   updated in patches.)
186 * Some files depend on special tools.  E.g., files ending in .gperf
187   need a `gperf' program.  The GNU version (part of libg++) is known
188   to work while some vendor versions do not.
190   You should not need these tools unless you change the source files.
192 * Some scripts need perl5 - but at the moment those scripts are not
193   vital for building and installing GNU libc (some data files will not
194   be created).
196 * When compiling for Linux, the header files of the Linux kernel must
197   be available to the compiler as <linux/*.h> and <asm/*.h>.
199 * lots of disk space (~170MB for i?86-linux; more for RISC platforms).
201 * plenty of time.  Compiling just the shared and static libraries for
202   i?86-linux takes approximately 1h on an i586@133, or 2.5h on
203   i486@66, or 4.5h on i486@33.  Multiply this by 1.5 or 2.0 if you
204   build profiling and/or the highly optimized version as well.  For
205   Hurd systems times are much higher.
207   You should avoid compiling in a NFS mounted filesystem.  This is
208   very slow.
210   James Troup <J.J.Troup@comp.brad.ac.uk> reports a compile time of
211   45h34m for a full build (shared, static, and profiled) on Atari
212   Falcon (Motorola 68030 @ 16 Mhz, 14 Mb memory) and Jan Barte
213   <yann@plato.uni-paderborn.de> reports 22h48m on Atari TT030
214   (Motorola 68030 @ 32 Mhz, 34 Mb memory)
216   If you have some more measurements let me know.
219 1.6.    When I run `nm -u libc.so' on the produced library I still
220         find unresolved symbols.  Can this be ok?
222 {UD} Yes, this is ok.  There can be several kinds of unresolved
223 symbols:
225 * magic symbols automatically generated by the linker.  These have names
226   like __start_* and __stop_*
228 * symbols starting with _dl_* come from the dynamic linker
230 * symbols resolved by using libgcc.a
231   (__udivdi3, __umoddi3, or similar)
233 * weak symbols, which need not be resolved at all (fabs for example)
235 Generally, you should make sure you find a real program which produces
236 errors while linking before deciding there is a problem.
239 1.7.    What are these `add-ons'?
241 {UD} To avoid complications with export rules or external source
242 code some optional parts of the libc are distributed as separate
243 packages (e.g., the crypt package, see question 2.5).
245 To use these packages as part of GNU libc, just unpack the tarfiles in
246 the libc source directory and tell the configuration script about them
247 using the --enable-add-ons option.  If you give just --enable-add-ons
248 configure tries to find all the add-on packages in your source tree.
249 This may not work.  If it doesn't, or if you want to select only a
250 subset of the add-ons, give a comma-separated list of the add-ons to
251 enable:
253         configure --enable-add-ons=crypt,linuxthreads
255 for example.
257 Add-ons can add features (including entirely new shared libraries),
258 override files, provide support for additional architectures, and
259 just about anything else.  The existing makefiles do most of the work;
260 only some few stub rules must be written to get everything running.
263 1.8.    My XXX kernel emulates a floating-point coprocessor for me.
264         Should I enable --with-fp?
266 {ZW} An emulated FPU is just as good as a real one, as far as the C
267 library is concerned.  You only need to say --without-fp if your
268 machine has no way to execute floating-point instructions.
270 People who are interested in squeezing the last drop of performance
271 out of their machine may wish to avoid the trap overhead, but this is
272 far more trouble than it's worth: you then have to compile
273 *everything* this way, including the compiler's internal libraries
274 (libgcc.a for GNU C), because the calling conventions change.
277 1.9.    When compiling GNU libc I get lots of errors saying functions
278         in glibc are duplicated in libgcc.
280 {EY} This is *exactly* the same problem that I was having.  The
281 problem was due to the fact that configure didn't correctly detect
282 that the linker flag --no-whole-archive was supported in my linker.
283 In my case it was because I had run ./configure with bogus CFLAGS, and
284 the test failed.
286 One thing that is particularly annoying about this problem is that
287 once this is misdetected, running configure again won't fix it unless
288 you first delete config.cache.
290 {UD} Starting with glibc-2.0.3 there should be a better test to avoid
291 some problems of this kind.  The setting of CFLAGS is checked at the
292 very beginning and if it is not usable `configure' will bark.
295 1.10.   What's the problem with configure --enable-omitfp?
297 {AJ} When --enable-omitfp is set the libraries are built without frame
298 pointers. Some compilers produce buggy code for this model and
299 therefore we don't advise using it at the moment.
301 If you use --enable-omitfp, you're on your own. If you encounter
302 problems with a library that was build this way, we advise you to
303 rebuild the library without --enable-omitfp.  If the problem vanishes
304 consider tracking the problem down and report it as compiler failure.
306 Since a library build with --enable-omitfp is undebuggable on most
307 systems, debuggable libraries are also built - you can use it by
308 appending "_g" to the library names.
310 The compilation of these extra libraries and the compiler optimizations
311 slow down the build process and need more disk space.
314 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
316 2. Installation and configuration issues
318 2.1.    Can I replace the libc on my Linux system with GNU libc?
320 {UD} You cannot replace any existing libc for Linux with GNU
321 libc.  It is binary incompatible and therefore has a different major
322 version.  You can, however, install it alongside your existing libc.
324 For Linux there are three major libc versions:
325         libc-4          a.out libc
326         libc-5          original ELF libc
327         libc-6          GNU libc
329 You can have any combination of these three installed.  For more
330 information consult documentation for shared library handling.  The
331 Makefiles of GNU libc will automatically generate the needed symbolic
332 links which the linker will use.
335 2.2.    How do I configure GNU libc so that the essential libraries
336         like libc.so go into /lib and the other into /usr/lib?
338 {UD,AJ} Like all other GNU packages GNU libc is designed to use a base
339 directory and install all files relative to this.  The default is
340 /usr/local, because this is safe (it will not damage the system if
341 installed there).  If you wish to install GNU libc as the primary C
342 library on your system, set the base directory to /usr (i.e. run
343 configure --prefix=/usr <other_options>).  Note that this can damage
344 your system; see question 2.3 for details.
346 Some systems like Linux have a filesystem standard which makes a
347 difference between essential libraries and others.  Essential
348 libraries are placed in /lib because this directory is required to be
349 located on the same disk partition as /.  The /usr subtree might be
350 found on another partition/disk. If you configure for Linux with
351 --prefix=/usr, then this will be done automatically.
353 To install the essential libraries which come with GNU libc in /lib on
354 systems other than Linux one must explicitly request it.  Autoconf has
355 no option for this so you have to use a `configparms' file (see the
356 `INSTALL' file for details).  It should contain:
358 slibdir=/lib
359 sysconfdir=/etc
361 The first line specifies the directory for the essential libraries,
362 the second line the directory for system configuration files.
365 2.3.    How should I avoid damaging my system when I install GNU libc?
367 {ZW} If you wish to be cautious, do not configure with --prefix=/usr.
368 If you don't specify a prefix, glibc will be installed in /usr/local,
369 where it will probably not break anything.  (If you wish to be
370 certain, set the prefix to something like /usr/local/glibc2 which is
371 not used for anything.)
373 The dangers when installing glibc in /usr are twofold:
375 * glibc will overwrite the headers in /usr/include.  Other C libraries
376   install a different but overlapping set of headers there, so the
377   effect will probably be that you can't compile anything.  You need to
378   rename /usr/include out of the way first.  (Do not throw it away; you
379   will then lose the ability to compile programs against your old libc.)
381 * None of your old libraries, static or shared, can be used with a
382   different C library major version.  For shared libraries this is not a
383   problem, because the filenames are different and the dynamic linker
384   will enforce the restriction.  But static libraries have no version
385   information.  You have to evacuate all the static libraries in
386   /usr/lib to a safe location.
388 The situation is rather similar to the move from a.out to ELF which
389 long-time Linux users will remember.
392 2.4.    Do I need to use GNU CC to compile programs that will use the
393         GNU C Library?
395 {ZW} In theory, no; the linker does not care, and the headers are
396 supposed to check for GNU CC before using its extensions to the C
397 language.
399 However, there are currently no ports of glibc to systems where
400 another compiler is the default, so no one has tested the headers
401 extensively against another compiler.  You may therefore encounter
402 difficulties.  If you do, please report them as bugs.
404 Also, in several places GNU extensions provide large benefits in code
405 quality.  For example, the library has hand-optimized, inline assembly
406 versions of some functions.  These can only be used with GCC.
409 2.5.    When linking with the new libc I get unresolved symbols
410         `crypt' and `setkey'.  Why aren't these functions in the
411         libc anymore?
413 {UD} The US places restrictions on exporting cryptographic programs
414 and source code.  Until this law gets abolished we cannot ship the
415 cryptographic functions together with glibc.
417 The functions are available, as an add-on (see question 1.7).  People in the
418 US may get it from the same place they got GNU libc from.  People
419 outside the US should get the code from ftp://ftp.ifi.uio.no/pub/gnu,
420 or another archive site outside the USA.  The README explains how to
421 install the sources.
423 If you already have the crypt code on your system the reason for the
424 failure is probably that you did not link with -lcrypt.  The crypto
425 functions are in a separate library to make it possible to export GNU
426 libc binaries from the US.
429 2.6.    When I use GNU libc on my Linux system by linking against
430         the libc.so which comes with glibc all I get is a core dump.
432 {UD} On Linux, gcc sets the dynamic linker to /lib/ld-linux.so.1
433 unless the user specifies a -dynamic-linker argument.  This is the
434 name of the libc5 dynamic linker, which does not work with glibc.
436 For casual use of GNU libc you can just specify
437     -dynamic-linker=/lib/ld-linux.so.2
439 which is the glibc dynamic linker, on Linux systems.  On other systems
440 the name is /lib/ld.so.1.
442 To change your environment to use GNU libc for compiling you need to
443 change the `specs' file of your gcc.  This file is normally found at
445         /usr/lib/gcc-lib/<arch>/<version>/specs
447 In this file you have to change a few things:
449 - change `ld-linux.so.1' to `ld-linux.so.2'
451 - remove all expression `%{...:-lgmon}';  there is no libgmon in glibc
453 - fix a minor bug by changing %{pipe:-} to %|
455 Here is what the gcc-2.7.2 specs file should look like when GNU libc
456 is installed at /usr:
458 -----------------------------------------------------------------------
459 *asm:
460 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
462 *asm_final:
465 *cpp:
466 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
468 *cc1:
469 %{profile:-p}
471 *cc1plus:
474 *endfile:
475 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
477 *link:
478 -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:        %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
480 *lib:
481 %{!shared: %{pthread:-lpthread}         %{profile:-lc_p} %{!profile: -lc}}
483 *libgcc:
484 -lgcc
486 *startfile:
487 %{!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}
489 *switches_need_spaces:
492 *signed_char:
493 %{funsigned-char:-D__CHAR_UNSIGNED__}
495 *predefines:
496 -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
498 *cross_compile:
501 *multilib:
502 . ;
504 -----------------------------------------------------------------------
506 Things get a bit more complicated if you have GNU libc installed in
507 some other place than /usr, i.e., if you do not want to use it instead
508 of the old libc.  In this case the needed startup files and libraries
509 are not found in the regular places.  So the specs file must tell the
510 compiler and linker exactly what to use.
512 Version 2.7.2.3 does and future versions of GCC will automatically
513 provide the correct specs.
516 2.7.    Looking through the shared libc file I haven't found the
517         functions `stat', `lstat', `fstat', and `mknod' and while
518         linking on my Linux system I get error messages.  How is
519         this supposed to work?
521 {RM} Believe it or not, stat and lstat (and fstat, and mknod)
522 are supposed to be undefined references in libc.so.6!  Your problem is
523 probably a missing or incorrect /usr/lib/libc.so file; note that this
524 is a small text file now, not a symlink to libc.so.6.  It should look
525 something like this:
527 GROUP ( libc.so.6 ld.so.1 libc.a )
529 or in ix86/Linux and alpha/Linux:
531 GROUP ( libc.so.6 ld-linux.so.2 libc.a )
534 2.8.    How can I compile gcc 2.7.2.1 from the gcc source code using
535         glibc 2.x?
537 {AJ} There's only correct support for glibc 2.0.x in gcc 2.7.2.3
538 or later.  You should get at least gcc 2.7.2.3.  All previous versions
539 had problems with glibc support.
542 2.9.    The `gencat' utility cannot process the catalog sources which
543         were used on my Linux libc5 based system.  Why?
545 {UD} The `gencat' utility provided with glibc complies to the XPG
546 standard.  The older Linux version did not obey the standard, so they
547 are not compatible.
549 To ease the transition from the Linux version some of the non-standard
550 features are also present in the `gencat' program of GNU libc.  This
551 mainly includes the use of symbols for the message number and the automatic
552 generation of header files which contain the needed #defines to map the
553 symbols to integers.
555 Here is a simple SED script to convert at least some Linux specific
556 catalog files to the XPG4 form:
558 -----------------------------------------------------------------------
559 # Change catalog source in Linux specific format to standard XPG format.
560 # Ulrich Drepper <drepper@cygnus.com>, 1996.
562 /^\$ #/ {
563   h
564   s/\$ #\([^ ]*\).*/\1/
565   x
566   s/\$ #[^ ]* *\(.*\)/\$ \1/
569 /^# / {
570   s/^# \(.*\)/\1/
571   G
572   s/\(.*\)\n\(.*\)/\2 \1/
574 -----------------------------------------------------------------------
577 2.10.   I have set up /etc/nis.conf, and the Linux libc 5 with NYS
578         works great.  But the glibc NIS+ doesn't seem to work.
580 {TK} The glibc NIS+ implementation uses a /var/nis/NIS_COLD_START
581 file for storing information about the NIS+ server and their public
582 keys, because the nis.conf file does not contain all the necessary
583 information.  You have to copy a NIS_COLD_START file from a Solaris
584 client (the NIS_COLD_START file is byte order independent) or generate
585 it with nisinit from the nis-tools package (available at
586 http://www-vt.uni-paderborn.de/~kukuk/linux/nisplus.html).
589 +2.11.  I have killed ypbind to stop using NIS, but glibc will
590         continue using NIS.
592 {TK} For faster NIS lookups, glibc uses the /var/yp/binding/ files
593 from ypbind.  ypbind 3.3 and older versions don't always remove these
594 files, so glibc will use them furthermore.  Other BSD versions seem to
595 work correct.  Until ypbind 3.4 is released, you can find a patch at
596 ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypbind-3.3-glibc2.diff.
598 2.12.   After installing glibc name resolving doesn't work properly.
600 {AJ} You probably should read the manual section describing
601 nsswitch.conf (just type `info libc "NSS Configuration File"').
602 The NSS configuration file is usually the culprit.
605 2.13.   I have /usr/include/net and /usr/include/scsi as symlinks
606         into my Linux source tree.  Is that wrong?
608 {PB} This was necessary for libc5, but is not correct when using
609 glibc.  Including the kernel header files directly in user programs
610 usually does not work (see question 3.5).  glibc provides its own <net/*>
611 and <scsi/*> header files to replace them, and you may have to remove
612 any symlink that you have in place before you install glibc.  However,
613 /usr/include/asm and /usr/include/linux should remain as they were.
616 2.14.   Programs like `logname', `top', `uptime' `users', `w' and
617         `who', show incorrect information about the (number of)
618         users on my system.  Why?
620 {MK} See question 3.2.
623 2.15.   When I start the program XXX after upgrading the library
624         I get
625           XXX: Symbol `_sys_errlist' has different size in shared
626           object, consider re-linking
627         Why?  What should I do?
629 {UD} As the message says, relink the binary.  The problem is that
630 a few symbols from the library can change in size and there is no way
631 to avoid this.  _sys_errlist is a good example.  Occasionally there are
632 new error numbers added to the kernel and this must be reflected at user
633 level, breaking programs that refer to them directly.
635 Such symbols should normally not be used at all.  There are mechanisms
636 to avoid using them.  In the case of _sys_errlist, there is the
637 strerror() function which should _always_ be used instead.  So the
638 correct fix is to rewrite that part of the application.
640 In some situations (especially when testing a new library release) it
641 might be possible that a symbol changed size when that should not have
642 happened.  So in case of doubt report such a warning message as a
643 problem.
646 2.16.   What do I need for C++ development?
648 {HJ,AJ} You need either egcs 1.0.1 or gcc-2.8.1 with libstdc++
649 2.8.1 (or more recent versions). libg++ 2.7.2 (and the Linux Versions
650 2.7.2.x) doesn't work very well with the GNU C library due to vtable thunks.
651 If you're upgrading from glibc 2.0.x to 2.1 you have to recompile
652 libstc++ since the library compiled for 2.0 is not compatible due to the new
653 Large File Support (LFS) in version 2.1.
656 2.17    Programs using libc have their messages translated, but other
657         behavior is not localized (e.g. collating order); why?
659 {ZW} Translated messages are automatically installed, but the locale
660 database that controls other behaviors is not.  You need to run
661 localedef to install this database, after you have run `make
662 install'.  For example, to set up the French Canadian locale, simply
663 issue the command
665     localedef -i fr_CA -f ISO-8859-1 fr_CA
667 Please see localedata/README in the source tree for further details.
668 You only get the locale database if the localedata add-on is installed
669 when building the GNU C library.
672 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
674 3. Source and binary incompatibilities, and what to do about them
676 3.1.    I expect GNU libc to be 100% source code compatible with
677         the old Linux based GNU libc.  Why isn't it like this?
679 {DMT,UD} Not every extension in Linux libc's history was well
680 thought-out.  In fact it had a lot of problems with standards compliance
681 and with cleanliness.  With the introduction of a new version number these
682 errors can now be corrected.  Here is a list of the known source code
683 incompatibilities:
685 * _GNU_SOURCE: glibc does not make the GNU extensions available
686   automatically.  If a program depends on GNU extensions or some
687   other non-standard functionality, it is necessary to compile it
688   with the C compiler option -D_GNU_SOURCE, or better, to put
689   `#define _GNU_SOURCE' at the beginning of your source files, before
690   any C library header files are included.  This difference normally
691   manifests itself in the form of missing prototypes and/or data type
692   definitions.  Thus, if you get such errors, the first thing you
693   should do is try defining _GNU_SOURCE and see if that makes the
694   problem go away.
696   For more information consult the file `NOTES' in the GNU C library
697   sources.
699 * reboot(): GNU libc sanitizes the interface of reboot() to be more
700   compatible with the interface used on other OSes.  reboot() as
701   implemented in glibc takes just one argument.  This argument
702   corresponds to the third argument of the Linux reboot system call.
703   That is, a call of the form reboot(a, b, c) needs to be changed into
704   reboot(c).  Beside this the header <sys/reboot.h> defines the needed
705   constants for the argument.  These RB_* constants should be used
706   instead of the cryptic magic numbers.
708 * swapon(): the interface of this function didn't change, but the
709   prototype is in a separate header file <sys/swap.h>.  This header
710   file also provides the SWAP_* constants defined by <linux/swap.h>;
711   you should use them for the second argument to swapon().
713 * errno: If a program uses the variable "errno", then it _must_
714   include <errno.h>.  The old libc often (erroneously) declared this
715   variable implicitly as a side-effect of including other libc header
716   files.  glibc is careful to avoid such namespace pollution, which,
717   in turn, means that you really need to include the header files that
718   you depend on.  This difference normally manifests itself in the
719   form of the compiler complaining about references to an undeclared
720   symbol "errno".
722 * Linux-specific syscalls: All Linux system calls now have appropriate
723   library wrappers and corresponding declarations in various header files.
724   This is because the syscall() macro that was traditionally used to
725   work around missing syscall wrappers are inherently non-portable and
726   error-prone.  The following table lists all the new syscall stubs,
727   the header-file declaring their interface and the system call name.
729        syscall name:    wrapper name:   declaring header file:
730        -------------    -------------   ----------------------
731        bdflush          bdflush         <sys/kdaemon.h>
732        syslog           ksyslog_ctl     <sys/klog.h>
734 * lpd: Older versions of lpd depend on a routine called _validuser().
735   The library does not provide this function, but instead provides
736   __ivaliduser() which has a slightly different interface.  Simply
737   upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
738   lpd is known to be working).
740 * resolver functions/BIND: like on many other systems the functions of
741   the resolver library are not included in libc itself.  There is a
742   separate library libresolv.  If you get undefined symbol errors for
743   symbols starting with `res_*' simply add -lresolv to your linker
744   command line.
746 * the `signal' function's behavior corresponds to the BSD semantic and
747   not the SysV semantic as it was in libc-5.  The interface on all GNU
748   systems shall be the same and BSD is the semantic of choice.  To use
749   the SysV behavior simply use `sysv_signal', or define _XOPEN_SOURCE.
750   See question 3.7 for details.
753 3.2.    Why does getlogin() always return NULL on my Linux box?
755 {UD} The GNU C library has a format for the UTMP and WTMP file which
756 differs from what your system currently has.  It was extended to
757 fulfill the needs of the next years when IPv6 is introduced.  The
758 record size is different and some fields have different positions.
759 The files written by functions from the one library cannot be read by
760 functions from the other library.  Sorry, but this is what a major
761 release is for.  It's better to have a cut now than having no means to
762 support the new techniques later.
765 3.3.    Where are the DST_* constants found in <sys/time.h> on many
766         systems?
768 {UD} These constants come from the old BSD days and are not used
769 anymore (libc5 does not actually implement the handling although the
770 constants are defined).
772 Instead GNU libc contains zone database support and compatibility code
773 for POSIX TZ environment variable handling.
776 3.4.    The prototypes for `connect', `accept', `getsockopt',
777         `setsockopt', `getsockname', `getpeername', `send',
778         `sendto', and `recvfrom' are different in GNU libc from
779         any other system I saw.  This is a bug, isn't it?
781 {UD} No, this is no bug.  This version of GNU libc already follows the
782 new Single Unix specifications (and I think the POSIX.1g draft which
783 adopted the solution).  The type for a parameter describing a size is
784 now `socklen_t', a new type.
787 3.5.    On Linux I've got problems with the declarations in Linux
788         kernel headers.
790 {UD,AJ} On Linux, the use of kernel headers is reduced to the minimum.
791 This gives Linus the ability to change the headers more freely.  Also,
792 user programs are now insulated from changes in the size of kernel
793 data structures.
795 For example, the sigset_t type is 32 or 64 bits wide in the kernel.
796 In glibc it is 1024 bits wide.  This guarantees that when the kernel
797 gets a bigger sigset_t (for POSIX.1e realtime support, say) user
798 programs will not have to be recompiled.  Consult the header files for
799 more information about the changes.
801 Therefore you shouldn't include Linux kernel header files directly if
802 glibc has defined a replacement. Otherwise you might get undefined
803 results because of type conflicts.
806 3.6.    I don't include any kernel headers myself but the compiler
807         still complains about redeclarations of types in the kernel
808         headers.
810 {UD} The kernel headers before Linux 2.1.61 and 2.0.32 don't work
811 correctly with glibc.  Compiling C programs is possible in most cases
812 but C++ programs have (due to the change of the name lookups for
813 `struct's) problems.  One prominent example is `struct fd_set'.
815 There might be some problems left but 2.1.61/2.0.32 fix most of the
816 known ones.  See the BUGS file for other known problems.
819 3.7.    Why don't signals interrupt system calls anymore?
821 {ZW} By default GNU libc uses the BSD semantics for signal(),
822 unlike Linux libc 5 which used System V semantics.  This is partially
823 for compatibility with other systems and partially because the BSD
824 semantics tend to make programming with signals easier.
826 There are three differences:
828 * BSD-style signals that occur in the middle of a system call do not
829   affect the system call; System V signals cause the system call to
830   fail and set errno to EINTR.
832 * BSD signal handlers remain installed once triggered.  System V signal
833   handlers work only once, so one must reinstall them each time.
835 * A BSD signal is blocked during the execution of its handler.  In other
836   words, a handler for SIGCHLD (for example) does not need to worry about
837   being interrupted by another SIGCHLD.  It may, however, be interrupted
838   by other signals.
840 There is general consensus that for `casual' programming with signals, the
841 BSD semantics are preferable.  You don't need to worry about system calls
842 returning EINTR, and you don't need to worry about the race conditions
843 associated with one-shot signal handlers.
845 If you are porting an old program that relies on the old semantics, you can
846 quickly fix the problem by changing signal() to sysv_signal() throughout.
847 Alternatively, define _XOPEN_SOURCE before including <signal.h>.
849 For new programs, the sigaction() function allows you to specify precisely
850 how you want your signals to behave.  All three differences listed above are
851 individually switchable on a per-signal basis with this function.
853 If all you want is for one specific signal to cause system calls to fail
854 and return EINTR (for example, to implement a timeout) you can do this with
855 siginterrupt().
858 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
860 4. Miscellaneous
862 4.1.    After I changed configure.in I get `Autoconf version X.Y.
863         or higher is required for this script'.  What can I do?
865 {UD} You have to get the specified autoconf version (or a later one)
866 from your favorite mirror of ftp.gnu.org.
869 4.2.    When I try to compile code which uses IPv6 headers and
870         definitions on my Linux 2.x.y system I am in trouble.
871         Nothing seems to work.
873 {UD} The problem is that IPv6 development still has not reached a
874 point where the headers are stable.  There are still lots of
875 incompatible changes made and the libc headers have to follow.
877 Also, make sure you have a suitably recent kernel.  As of the 970401
878 snapshot, according to Philip Blundell <Philip.Blundell@pobox.com>, the
879 required kernel version is at least 2.1.30.
882 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
884 Answers were given by:
885 {UD} Ulrich Drepper, <drepper@cygnus.com>
886 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
887 {RM} Roland McGrath, <roland@gnu.org>
888 {AJ} Andreas Jaeger, <aj@arthur.rhein-neckar.de>
889 {EY} Eric Youngdale, <eric@andante.jic.com>
890 {PB} Phil Blundell, <Philip.Blundell@pobox.com>
891 {MK} Mark Kettenis, <kettenis@phys.uva.nl>
892 {ZW} Zack Weinberg, <zack@rabi.phys.columbia.edu>
893 {TK} Thorsten Kukuk, <kukuk@vt.uni-paderborn.de>
895 Local Variables:
896  mode:outline
897  outline-regexp:"\\?"
898 End: