(glob_in_dir): Add support for cases insensitive VMS.
[glibc.git] / FAQ
bloba54db102da3da1576d6c7c99dfae1e98c2f42397
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.    What tools do I need for powerpc?
28 1.6.    Do I need some more things to compile GNU C Library?
29 1.7.    When I run `nm -u libc.so' on the produced library I still
30         find unresolved symbols.  Can this be ok?
31 1.8.    What are these `add-ons'?
32 1.9.    My XXX kernel emulates a floating-point coprocessor for me.
33         Should I enable --with-fp?
34 1.10.   When compiling GNU libc I get lots of errors saying functions
35         in glibc are duplicated in libgcc.
36 1.11.   Why do I get messages about missing thread functions when I use
37         the librt?  I don't even use threads.
38 1.12.   What's the problem with configure --enable-omitfp?
40 2. Installation and configuration issues
42 2.1.    Can I replace the libc on my Linux system with GNU libc?
43 2.2.    How do I configure GNU libc so that the essential libraries
44         like libc.so go into /lib and the other into /usr/lib?
45 2.3.    How should I avoid damaging my system when I install GNU libc?
46 2.4.    Do I need to use GNU CC to compile programs that will use the
47         GNU C Library?
48 2.5.    When linking with the new libc I get unresolved symbols
49         `crypt' and `setkey'.  Why aren't these functions in the
50         libc anymore?
51 2.6.    When I use GNU libc on my Linux system by linking against
52         the libc.so which comes with glibc all I get is a core dump.
53 2.7.    Looking through the shared libc file I haven't found the
54         functions `stat', `lstat', `fstat', and `mknod' and while
55         linking on my Linux system I get error messages.  How is
56         this supposed to work?
57 2.8.    How can I compile gcc 2.7.2.1 from the gcc source code using
58         glibc 2.x?
59 2.9.    The `gencat' utility cannot process the catalog sources which
60         were used on my Linux libc5 based system.  Why?
61 2.10.   I have set up /etc/nis.conf, and the Linux libc 5 with NYS
62         works great.  But the glibc NIS+ doesn't seem to work.
63 2.11.   I have killed ypbind to stop using NIS, but glibc will
64         continue using NIS.
65 2.12.   After installing glibc name resolving doesn't work properly.
66 2.13.   I have /usr/include/net and /usr/include/scsi as symlinks
67         into my Linux source tree.  Is that wrong?
68 2.14.   Programs like `logname', `top', `uptime' `users', `w' and
69         `who', show incorrect information about the (number of)
70         users on my system.  Why?
71 2.15.   After upgrading to glibc 2.1 with symbol versioning I get
72         errors about undefined symbols.  What went wrong?
73 2.16.   When I start the program XXX after upgrading the library
74         I get
75           XXX: Symbol `_sys_errlist' has different size in shared
76           object, consider re-linking
77         Why?  What should I do?
79 3. Source and binary incompatibilities, and what to do about them
81 3.1.    I expect GNU libc to be 100% source code compatible with
82         the old Linux based GNU libc.  Why isn't it like this?
83 3.2.    Why does getlogin() always return NULL on my Linux box?
84 3.3.    Where are the DST_* constants found in <sys/time.h> on many
85         systems?
86 3.4.    The prototypes for `connect', `accept', `getsockopt',
87         `setsockopt', `getsockname', `getpeername', `send',
88         `sendto', and `recvfrom' are different in GNU libc from
89         any other system I saw.  This is a bug, isn't it?
90 3.5.    On Linux I've got problems with the declarations in Linux
91         kernel headers.
92 3.6.    I don't include any kernel headers myself but the compiler
93         still complains about redeclarations of types in the kernel
94         headers.
95 3.7.    Why don't signals interrupt system calls anymore?
96 3.8.    I've got errors compiling code that uses certain string
97         functions.  Why?
98 3.9.    I get compiler messages "Initializer element not constant" with
99         stdin/stdout/stderr. Why?
100 3.10.   I can't compile with gcc -traditional (or
101         -traditional-cpp). Why?
102 3.11.   I get some errors with `gcc -ansi'. Isn't glibc ANSI compatible?
104 4. Miscellaneous
106 4.1.    After I changed configure.in I get `Autoconf version X.Y.
107         or higher is required for this script'.  What can I do?
108 4.2.    When I try to compile code which uses IPv6 headers and
109         definitions on my Linux 2.x.y system I am in trouble.
110         Nothing seems to work.
113 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
115 1. Compiling glibc
117 1.1.    What systems does the GNU C Library run on?
119 {UD} This is difficult to answer.  The file `README' lists the
120 architectures GNU libc was known to run on *at some time*.  This does
121 not mean that it still can be compiled and run on them now.
123 The systems glibc is known to work on as of this release, and most
124 probably in the future, are:
126         *-*-gnu                 GNU Hurd
127         i[3456]86-*-linux-gnu   Linux-2.x on Intel
128         m68k-*-linux-gnu        Linux-2.x on Motorola 680x0
129         alpha-*-linux-gnu       Linux-2.x on DEC Alpha
130         powerpc-*-linux-gnu     Linux and MkLinux on PowerPC systems
131         sparc-*-linux-gnu       Linux-2.x on SPARC
132         sparc64-*-linux-gnu     Linux-2.x on UltraSPARC
134 Ports to other Linux platforms are in development, and may in fact
135 work already, but no one has sent us success reports for them.
136 Currently no ports to other operating systems are underway, although a
137 few people have expressed interest.
139 If you have a system not listed above (or in the `README' file) and
140 you are really interested in porting it, contact
142         <bug-glibc@gnu.org>
145 1.2.    What compiler do I need to build GNU libc?
147 {UD} You must use GNU CC to compile GNU libc.  A lot of extensions of
148 GNU CC are used to increase portability and speed.
150 GNU CC is found, like all other GNU packages, on
151         ftp://prep.ai.mit.edu/pub/gnu
152 and the many mirror sites.  prep is always overloaded, so try to find
153 a local mirror first.
155 You always should try to use the latest official release.  Older
156 versions may not have all the features GNU libc requires.  On most
157 supported platforms (for powerpc see question question 1.5), 2.7.2.3 is
158 the earliest version that works at all.
161 1.3.    When I try to compile glibc I get only error messages.
162         What's wrong?
164 {UD} You definitely need GNU make to translate GNU libc.  No
165 other make program has the needed functionality.
167 We recommend version GNU make version 3.75.  Versions 3.76 and 3.76.1
168 have bugs which appear when building big projects like GNU libc.
169 Versions before 3.74 have bugs and/or are missing features.
172 1.4.    Do I need a special linker or archiver?
174 {UD} You may be able to use your system linker, but GNU libc works
175 best with GNU binutils.
177 On systems where the native linker does not support weak symbols you
178 will not get a fully ISO C compliant C library.  Generally speaking
179 you should use the GNU binutils if they provide at least the same
180 functionality as your system's tools.
182 Always get the newest release of GNU binutils available.  Older
183 releases are known to have bugs that prevent a successful compilation.
185 {ZW} As of release 2.1 a linker supporting symbol versions is
186 required.  For Linux, get binutils-2.8.1.0.17 or later.  Other systems
187 may have native linker support, but it's moot right now, because glibc
188 has not been ported to them.
191 1.5.    What tools do I need for powerpc?
193 {GK} For a successful installation you definitely need the most recent
194 tools. You can safely assume that anything earlier than binutils
195 2.8.1.0.17 and egcs-1.0 will have problems. We'd advise at the moment
196 binutils 2.8.1.0.18 and egcs-1.0.1.
198 In fact, egcs 1.0.1 currently has two serious bugs that prevent a
199 clean make; one relates to switch statement folding, for which there
200 is a temporary patch at
202 <http://discus.anu.edu.au/~geoffk/egcs-1.0-geoffk.diff.gz>
204 and the other relates to 'forbidden register spilled', for which the
205 workaround is to put
207 CFLAGS-condvar.c += -fno-inline
209 in configparms.  Later versions of egcs may fix these problems.
212 1.6.    Do I need some more things to compile GNU C Library?
214 {UD} Yes, there are some more :-).
216 * GNU gettext.  This package contains the tools needed to construct
217   `message catalog' files containing translated versions of system
218   messages. See ftp://prep.ai.mit.edu/pub/gnu or better any mirror
219   site.  (We distribute compiled message catalogs, but they may not be
220   updated in patches.)
222 * Some files depend on special tools.  E.g., files ending in .gperf
223   need a `gperf' program.  The GNU version (part of libg++) is known
224   to work while some vendor versions do not.
226   You should not need these tools unless you change the source files.
228 * Some scripts need perl5 - but at the moment those scripts are not
229   vital for building and installing GNU libc (some data files will not
230   be created).
232 * When compiling for Linux, the header files of the Linux kernel must
233   be available to the compiler as <linux/*.h> and <asm/*.h>.
235 * lots of disk space (~170MB for i?86-linux; more for RISC platforms).
237 * plenty of time.  Compiling just the shared and static libraries for
238   i?86-linux takes approximately 1h on an i586@133, or 2.5h on
239   i486@66, or 4.5h on i486@33.  Multiply this by 1.5 or 2.0 if you
240   build profiling and/or the highly optimized version as well.  For
241   Hurd systems times are much higher.
243   You should avoid compiling in a NFS mounted filesystem.  This is
244   very slow.
246   James Troup <J.J.Troup@comp.brad.ac.uk> reports a compile time of
247   45h34m for a full build (shared, static, and profiled) on Atari
248   Falcon (Motorola 68030 @ 16 Mhz, 14 Mb memory) and Jan Barte
249   <yann@plato.uni-paderborn.de> reports 22h48m on Atari TT030
250   (Motorola 68030 @ 32 Mhz, 34 Mb memory)
252   If you have some more measurements let me know.
255 1.7.    When I run `nm -u libc.so' on the produced library I still
256         find unresolved symbols.  Can this be ok?
258 {UD} Yes, this is ok.  There can be several kinds of unresolved
259 symbols:
261 * magic symbols automatically generated by the linker.  These have names
262   like __start_* and __stop_*
264 * symbols starting with _dl_* come from the dynamic linker
266 * symbols resolved by using libgcc.a
267   (__udivdi3, __umoddi3, or similar)
269 * weak symbols, which need not be resolved at all (fabs for example)
271 Generally, you should make sure you find a real program which produces
272 errors while linking before deciding there is a problem.
275 1.8.    What are these `add-ons'?
277 {UD} To avoid complications with export rules or external source
278 code some optional parts of the libc are distributed as separate
279 packages (e.g., the crypt package, see question 2.5).
281 To use these packages as part of GNU libc, just unpack the tarfiles in
282 the libc source directory and tell the configuration script about them
283 using the --enable-add-ons option.  If you give just --enable-add-ons
284 configure tries to find all the add-on packages in your source tree.
285 This may not work.  If it doesn't, or if you want to select only a
286 subset of the add-ons, give a comma-separated list of the add-ons to
287 enable:
289         configure --enable-add-ons=crypt,linuxthreads
291 for example.
293 Add-ons can add features (including entirely new shared libraries),
294 override files, provide support for additional architectures, and
295 just about anything else.  The existing makefiles do most of the work;
296 only some few stub rules must be written to get everything running.
299 1.9.    My XXX kernel emulates a floating-point coprocessor for me.
300         Should I enable --with-fp?
302 {ZW} An emulated FPU is just as good as a real one, as far as the C
303 library is concerned.  You only need to say --without-fp if your
304 machine has no way to execute floating-point instructions.
306 People who are interested in squeezing the last drop of performance
307 out of their machine may wish to avoid the trap overhead, but this is
308 far more trouble than it's worth: you then have to compile
309 *everything* this way, including the compiler's internal libraries
310 (libgcc.a for GNU C), because the calling conventions change.
313 1.10.   When compiling GNU libc I get lots of errors saying functions
314         in glibc are duplicated in libgcc.
316 {EY} This is *exactly* the same problem that I was having.  The
317 problem was due to the fact that configure didn't correctly detect
318 that the linker flag --no-whole-archive was supported in my linker.
319 In my case it was because I had run ./configure with bogus CFLAGS, and
320 the test failed.
322 One thing that is particularly annoying about this problem is that
323 once this is misdetected, running configure again won't fix it unless
324 you first delete config.cache.
326 {UD} Starting with glibc-2.0.3 there should be a better test to avoid
327 some problems of this kind.  The setting of CFLAGS is checked at the
328 very beginning and if it is not usable `configure' will bark.
331 1.11.   Why do I get messages about missing thread functions when I use
332         the librt?  I don't even use threads.
334 {UD} In this case you probably mixed up your installation of the libc.
335 The librt internally uses threads and it has implicit references to
336 the thread library.  Normally these references are satisfied
337 automatically but if the thread library belonging to the librt is not
338 in the expected place one has to specify this place.  When using GNU
339 ld it works like this:
341         gcc -o foo foo.c -Wl,-rpath-link=/some/other/dir -lrt
343 The `/some/other/dir' should contain the matching thread library and
344 `ld' will use the given path to find the implicitly referenced library
345 while not disturbing any other link path order.
348 1.12.   What's the problem with configure --enable-omitfp?
350 {AJ} When --enable-omitfp is set the libraries are built without frame
351 pointers. Some compilers produce buggy code for this model and
352 therefore we don't advise using it at the moment.
354 If you use --enable-omitfp, you're on your own. If you encounter
355 problems with a library that was build this way, we advise you to
356 rebuild the library without --enable-omitfp.  If the problem vanishes
357 consider tracking the problem down and report it as compiler failure.
359 Since a library build with --enable-omitfp is undebuggable on most
360 systems, debuggable libraries are also built - you can use it by
361 appending "_g" to the library names.
363 The compilation of these extra libraries and the compiler optimizations
364 slow down the build process and need more disk space.
367 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
369 2. Installation and configuration issues
371 2.1.    Can I replace the libc on my Linux system with GNU libc?
373 {UD} You cannot replace any existing libc for Linux with GNU
374 libc.  It is binary incompatible and therefore has a different major
375 version.  You can, however, install it alongside your existing libc.
377 For Linux there are three major libc versions:
378         libc-4          a.out libc
379         libc-5          original ELF libc
380         libc-6          GNU libc
382 You can have any combination of these three installed.  For more
383 information consult documentation for shared library handling.  The
384 Makefiles of GNU libc will automatically generate the needed symbolic
385 links which the linker will use.
388 2.2.    How do I configure GNU libc so that the essential libraries
389         like libc.so go into /lib and the other into /usr/lib?
391 {UD,AJ} Like all other GNU packages GNU libc is designed to use a base
392 directory and install all files relative to this.  The default is
393 /usr/local, because this is safe (it will not damage the system if
394 installed there).  If you wish to install GNU libc as the primary C
395 library on your system, set the base directory to /usr (i.e. run
396 configure --prefix=/usr <other_options>).  Note that this can damage
397 your system; see question 2.3 for details.
399 Some systems like Linux have a filesystem standard which makes a
400 difference between essential libraries and others.  Essential
401 libraries are placed in /lib because this directory is required to be
402 located on the same disk partition as /.  The /usr subtree might be
403 found on another partition/disk. If you configure for Linux with
404 --prefix=/usr, then this will be done automatically.
406 To install the essential libraries which come with GNU libc in /lib on
407 systems other than Linux one must explicitly request it.  Autoconf has
408 no option for this so you have to use a `configparms' file (see the
409 `INSTALL' file for details).  It should contain:
411 slibdir=/lib
412 sysconfdir=/etc
414 The first line specifies the directory for the essential libraries,
415 the second line the directory for system configuration files.
418 2.3.    How should I avoid damaging my system when I install GNU libc?
420 {ZW} If you wish to be cautious, do not configure with --prefix=/usr.
421 If you don't specify a prefix, glibc will be installed in /usr/local,
422 where it will probably not break anything.  (If you wish to be
423 certain, set the prefix to something like /usr/local/glibc2 which is
424 not used for anything.)
426 The dangers when installing glibc in /usr are twofold:
428 * glibc will overwrite the headers in /usr/include.  Other C libraries
429   install a different but overlapping set of headers there, so the
430   effect will probably be that you can't compile anything.  You need to
431   rename /usr/include out of the way first.  (Do not throw it away; you
432   will then lose the ability to compile programs against your old libc.)
434 * None of your old libraries, static or shared, can be used with a
435   different C library major version.  For shared libraries this is not a
436   problem, because the filenames are different and the dynamic linker
437   will enforce the restriction.  But static libraries have no version
438   information.  You have to evacuate all the static libraries in
439   /usr/lib to a safe location.
441 The situation is rather similar to the move from a.out to ELF which
442 long-time Linux users will remember.
445 2.4.    Do I need to use GNU CC to compile programs that will use the
446         GNU C Library?
448 {ZW} In theory, no; the linker does not care, and the headers are
449 supposed to check for GNU CC before using its extensions to the C
450 language.
452 However, there are currently no ports of glibc to systems where
453 another compiler is the default, so no one has tested the headers
454 extensively against another compiler.  You may therefore encounter
455 difficulties.  If you do, please report them as bugs.
457 Also, in several places GNU extensions provide large benefits in code
458 quality.  For example, the library has hand-optimized, inline assembly
459 versions of some string functions.  These can only be used with GCC.
460 See question 3.8 for details.
463 2.5.    When linking with the new libc I get unresolved symbols
464         `crypt' and `setkey'.  Why aren't these functions in the
465         libc anymore?
467 {UD} The US places restrictions on exporting cryptographic programs
468 and source code.  Until this law gets abolished we cannot ship the
469 cryptographic functions together with glibc.
471 The functions are available, as an add-on (see question 1.8).  People in the
472 US may get it from the same place they got GNU libc from.  People
473 outside the US should get the code from ftp://ftp.ifi.uio.no/pub/gnu,
474 or another archive site outside the USA.  The README explains how to
475 install the sources.
477 If you already have the crypt code on your system the reason for the
478 failure is probably that you did not link with -lcrypt.  The crypto
479 functions are in a separate library to make it possible to export GNU
480 libc binaries from the US.
483 2.6.    When I use GNU libc on my Linux system by linking against
484         the libc.so which comes with glibc all I get is a core dump.
486 {UD} On Linux, gcc sets the dynamic linker to /lib/ld-linux.so.1
487 unless the user specifies a -dynamic-linker argument.  This is the
488 name of the libc5 dynamic linker, which does not work with glibc.
490 For casual use of GNU libc you can just specify
491     -dynamic-linker=/lib/ld-linux.so.2
493 which is the glibc dynamic linker, on Linux systems.  On other systems
494 the name is /lib/ld.so.1.
496 To change your environment to use GNU libc for compiling you need to
497 change the `specs' file of your gcc.  This file is normally found at
499         /usr/lib/gcc-lib/<arch>/<version>/specs
501 In this file you have to change a few things:
503 - change `ld-linux.so.1' to `ld-linux.so.2'
505 - remove all expression `%{...:-lgmon}';  there is no libgmon in glibc
507 - fix a minor bug by changing %{pipe:-} to %|
509 Here is what the gcc-2.7.2 specs file should look like when GNU libc
510 is installed at /usr:
512 -----------------------------------------------------------------------
513 *asm:
514 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
516 *asm_final:
519 *cpp:
520 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
522 *cc1:
523 %{profile:-p}
525 *cc1plus:
528 *endfile:
529 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
531 *link:
532 -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:        %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
534 *lib:
535 %{!shared: %{pthread:-lpthread}         %{profile:-lc_p} %{!profile: -lc}}
537 *libgcc:
538 -lgcc
540 *startfile:
541 %{!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}
543 *switches_need_spaces:
546 *signed_char:
547 %{funsigned-char:-D__CHAR_UNSIGNED__}
549 *predefines:
550 -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
552 *cross_compile:
555 *multilib:
556 . ;
558 -----------------------------------------------------------------------
560 Things get a bit more complicated if you have GNU libc installed in
561 some other place than /usr, i.e., if you do not want to use it instead
562 of the old libc.  In this case the needed startup files and libraries
563 are not found in the regular places.  So the specs file must tell the
564 compiler and linker exactly what to use.
566 Version 2.7.2.3 does and future versions of GCC will automatically
567 provide the correct specs.
570 2.7.    Looking through the shared libc file I haven't found the
571         functions `stat', `lstat', `fstat', and `mknod' and while
572         linking on my Linux system I get error messages.  How is
573         this supposed to work?
575 {RM} Believe it or not, stat and lstat (and fstat, and mknod)
576 are supposed to be undefined references in libc.so.6!  Your problem is
577 probably a missing or incorrect /usr/lib/libc.so file; note that this
578 is a small text file now, not a symlink to libc.so.6.  It should look
579 something like this:
581 GROUP ( libc.so.6 ld.so.1 libc.a )
583 or in ix86/Linux and alpha/Linux:
585 GROUP ( libc.so.6 ld-linux.so.2 libc.a )
588 2.8.    How can I compile gcc 2.7.2.1 from the gcc source code using
589         glibc 2.x?
591 {AJ} There's only correct support for glibc 2.0.x in gcc 2.7.2.3
592 or later.  You should get at least gcc 2.7.2.3.  All previous versions
593 had problems with glibc support.
596 2.9.    The `gencat' utility cannot process the catalog sources which
597         were used on my Linux libc5 based system.  Why?
599 {UD} The `gencat' utility provided with glibc complies to the XPG
600 standard.  The older Linux version did not obey the standard, so they
601 are not compatible.
603 To ease the transition from the Linux version some of the non-standard
604 features are also present in the `gencat' program of GNU libc.  This
605 mainly includes the use of symbols for the message number and the automatic
606 generation of header files which contain the needed #defines to map the
607 symbols to integers.
609 Here is a simple SED script to convert at least some Linux specific
610 catalog files to the XPG4 form:
612 -----------------------------------------------------------------------
613 # Change catalog source in Linux specific format to standard XPG format.
614 # Ulrich Drepper <drepper@cygnus.com>, 1996.
616 /^\$ #/ {
617   h
618   s/\$ #\([^ ]*\).*/\1/
619   x
620   s/\$ #[^ ]* *\(.*\)/\$ \1/
623 /^# / {
624   s/^# \(.*\)/\1/
625   G
626   s/\(.*\)\n\(.*\)/\2 \1/
628 -----------------------------------------------------------------------
631 2.10.   I have set up /etc/nis.conf, and the Linux libc 5 with NYS
632         works great.  But the glibc NIS+ doesn't seem to work.
634 {TK} The glibc NIS+ implementation uses a /var/nis/NIS_COLD_START
635 file for storing information about the NIS+ server and their public
636 keys, because the nis.conf file does not contain all the necessary
637 information.  You have to copy a NIS_COLD_START file from a Solaris
638 client (the NIS_COLD_START file is byte order independent) or generate
639 it with nisinit from the nis-tools package (available at
640 http://www-vt.uni-paderborn.de/~kukuk/linux/nisplus.html).
643 2.11.   I have killed ypbind to stop using NIS, but glibc will
644         continue using NIS.
646 {TK} For faster NIS lookups, glibc uses the /var/yp/binding/ files
647 from ypbind.  ypbind 3.3 and older versions don't always remove these
648 files, so glibc will use them furthermore.  Other BSD versions seem to
649 work correct.  Until ypbind 3.4 is released, you can find a patch at
650 ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypbind-3.3-glibc2.diff.
653 2.12.   After installing glibc name resolving doesn't work properly.
655 {AJ} You probably should read the manual section describing
656 nsswitch.conf (just type `info libc "NSS Configuration File"').
657 The NSS configuration file is usually the culprit.
660 2.13.   I have /usr/include/net and /usr/include/scsi as symlinks
661         into my Linux source tree.  Is that wrong?
663 {PB} This was necessary for libc5, but is not correct when using
664 glibc.  Including the kernel header files directly in user programs
665 usually does not work (see question 3.5).  glibc provides its own <net/*>
666 and <scsi/*> header files to replace them, and you may have to remove
667 any symlink that you have in place before you install glibc.  However,
668 /usr/include/asm and /usr/include/linux should remain as they were.
671 2.14.   Programs like `logname', `top', `uptime' `users', `w' and
672         `who', show incorrect information about the (number of)
673         users on my system.  Why?
675 {MK} See question 3.2.
678 2.15.   After upgrading to glibc 2.1 with symbol versioning I get
679         errors about undefined symbols.  What went wrong?
681 {AJ} The problem is caused either by wrong program code or tools.  In
682 the versioned libc a lot of symbols are now local that were global
683 symbols in previous versions.  It seems that programs linked against
684 older versions often accidentally used libc global variables --
685 something that should not happen.
687 The only way to fix this is to recompile your program. Sorry, that's
688 the price you might have to pay once for quite a number of advantages
689 with symbol versioning.
692 2.16.   When I start the program XXX after upgrading the library
693         I get
694           XXX: Symbol `_sys_errlist' has different size in shared
695           object, consider re-linking
696         Why?  What should I do?
698 {UD} As the message says, relink the binary.  The problem is that
699 a few symbols from the library can change in size and there is no way
700 to avoid this.  _sys_errlist is a good example.  Occasionally there are
701 new error numbers added to the kernel and this must be reflected at user
702 level, breaking programs that refer to them directly.
704 Such symbols should normally not be used at all.  There are mechanisms
705 to avoid using them.  In the case of _sys_errlist, there is the
706 strerror() function which should _always_ be used instead.  So the
707 correct fix is to rewrite that part of the application.
709 In some situations (especially when testing a new library release) it
710 might be possible that a symbol changed size when that should not have
711 happened.  So in case of doubt report such a warning message as a
712 problem.
715 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
717 3. Source and binary incompatibilities, and what to do about them
719 3.1.    I expect GNU libc to be 100% source code compatible with
720         the old Linux based GNU libc.  Why isn't it like this?
722 {DMT,UD} Not every extension in Linux libc's history was well
723 thought-out.  In fact it had a lot of problems with standards compliance
724 and with cleanliness.  With the introduction of a new version number these
725 errors can now be corrected.  Here is a list of the known source code
726 incompatibilities:
728 * _GNU_SOURCE: glibc does not make the GNU extensions available
729   automatically.  If a program depends on GNU extensions or some
730   other non-standard functionality, it is necessary to compile it
731   with the C compiler option -D_GNU_SOURCE, or better, to put
732   `#define _GNU_SOURCE' at the beginning of your source files, before
733   any C library header files are included.  This difference normally
734   manifests itself in the form of missing prototypes and/or data type
735   definitions.  Thus, if you get such errors, the first thing you
736   should do is try defining _GNU_SOURCE and see if that makes the
737   problem go away.
739   For more information consult the file `NOTES' in the GNU C library
740   sources.
742 * reboot(): GNU libc sanitizes the interface of reboot() to be more
743   compatible with the interface used on other OSes.  reboot() as
744   implemented in glibc takes just one argument.  This argument
745   corresponds to the third argument of the Linux reboot system call.
746   That is, a call of the form reboot(a, b, c) needs to be changed into
747   reboot(c).  Beside this the header <sys/reboot.h> defines the needed
748   constants for the argument.  These RB_* constants should be used
749   instead of the cryptic magic numbers.
751 * swapon(): the interface of this function didn't change, but the
752   prototype is in a separate header file <sys/swap.h>.  This header
753   file also provides the SWAP_* constants defined by <linux/swap.h>;
754   you should use them for the second argument to swapon().
756 * errno: If a program uses the variable "errno", then it _must_
757   include <errno.h>.  The old libc often (erroneously) declared this
758   variable implicitly as a side-effect of including other libc header
759   files.  glibc is careful to avoid such namespace pollution, which,
760   in turn, means that you really need to include the header files that
761   you depend on.  This difference normally manifests itself in the
762   form of the compiler complaining about references to an undeclared
763   symbol "errno".
765 * Linux-specific syscalls: All Linux system calls now have appropriate
766   library wrappers and corresponding declarations in various header files.
767   This is because the syscall() macro that was traditionally used to
768   work around missing syscall wrappers are inherently non-portable and
769   error-prone.  The following table lists all the new syscall stubs,
770   the header-file declaring their interface and the system call name.
772        syscall name:    wrapper name:   declaring header file:
773        -------------    -------------   ----------------------
774        bdflush          bdflush         <sys/kdaemon.h>
775        syslog           ksyslog_ctl     <sys/klog.h>
777 * lpd: Older versions of lpd depend on a routine called _validuser().
778   The library does not provide this function, but instead provides
779   __ivaliduser() which has a slightly different interface.  Simply
780   upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
781   lpd is known to be working).
783 * resolver functions/BIND: like on many other systems the functions of
784   the resolver library are not included in libc itself.  There is a
785   separate library libresolv.  If you get undefined symbol errors for
786   symbols starting with `res_*' simply add -lresolv to your linker
787   command line.
789 * the `signal' function's behavior corresponds to the BSD semantic and
790   not the SysV semantic as it was in libc-5.  The interface on all GNU
791   systems shall be the same and BSD is the semantic of choice.  To use
792   the SysV behavior simply use `sysv_signal', or define _XOPEN_SOURCE.
793   See question 3.7 for details.
796 3.2.    Why does getlogin() always return NULL on my Linux box?
798 {UD} The GNU C library has a format for the UTMP and WTMP file which
799 differs from what your system currently has.  It was extended to
800 fulfill the needs of the next years when IPv6 is introduced.  The
801 record size is different and some fields have different positions.
802 The files written by functions from the one library cannot be read by
803 functions from the other library.  Sorry, but this is what a major
804 release is for.  It's better to have a cut now than having no means to
805 support the new techniques later.
807 {MK} There is however a (partial) solution for this problem.  Please
808 take a look at the file `login/README.utmpd'.
811 3.3.    Where are the DST_* constants found in <sys/time.h> on many
812         systems?
814 {UD} These constants come from the old BSD days and are not used
815 anymore (libc5 does not actually implement the handling although the
816 constants are defined).
818 Instead GNU libc contains zone database support and compatibility code
819 for POSIX TZ environment variable handling.
822 3.4.    The prototypes for `connect', `accept', `getsockopt',
823         `setsockopt', `getsockname', `getpeername', `send',
824         `sendto', and `recvfrom' are different in GNU libc from
825         any other system I saw.  This is a bug, isn't it?
827 {UD} No, this is no bug.  This version of GNU libc already follows the
828 new Single Unix specifications (and I think the POSIX.1g draft which
829 adopted the solution).  The type for a parameter describing a size is
830 now `socklen_t', a new type.
833 3.5.    On Linux I've got problems with the declarations in Linux
834         kernel headers.
836 {UD,AJ} On Linux, the use of kernel headers is reduced to the minimum.
837 This gives Linus the ability to change the headers more freely.  Also,
838 user programs are now insulated from changes in the size of kernel
839 data structures.
841 For example, the sigset_t type is 32 or 64 bits wide in the kernel.
842 In glibc it is 1024 bits wide.  This guarantees that when the kernel
843 gets a bigger sigset_t (for POSIX.1e realtime support, say) user
844 programs will not have to be recompiled.  Consult the header files for
845 more information about the changes.
847 Therefore you shouldn't include Linux kernel header files directly if
848 glibc has defined a replacement. Otherwise you might get undefined
849 results because of type conflicts.
852 3.6.    I don't include any kernel headers myself but the compiler
853         still complains about redeclarations of types in the kernel
854         headers.
856 {UD} The kernel headers before Linux 2.1.61 and 2.0.32 don't work
857 correctly with glibc.  Compiling C programs is possible in most cases
858 but C++ programs have (due to the change of the name lookups for
859 `struct's) problems.  One prominent example is `struct fd_set'.
861 There might be some problems left but 2.1.61/2.0.32 fix most of the
862 known ones.  See the BUGS file for other known problems.
865 3.7.    Why don't signals interrupt system calls anymore?
867 {ZW} By default GNU libc uses the BSD semantics for signal(),
868 unlike Linux libc 5 which used System V semantics.  This is partially
869 for compatibility with other systems and partially because the BSD
870 semantics tend to make programming with signals easier.
872 There are three differences:
874 * BSD-style signals that occur in the middle of a system call do not
875   affect the system call; System V signals cause the system call to
876   fail and set errno to EINTR.
878 * BSD signal handlers remain installed once triggered.  System V signal
879   handlers work only once, so one must reinstall them each time.
881 * A BSD signal is blocked during the execution of its handler.  In other
882   words, a handler for SIGCHLD (for example) does not need to worry about
883   being interrupted by another SIGCHLD.  It may, however, be interrupted
884   by other signals.
886 There is general consensus that for `casual' programming with signals, the
887 BSD semantics are preferable.  You don't need to worry about system calls
888 returning EINTR, and you don't need to worry about the race conditions
889 associated with one-shot signal handlers.
891 If you are porting an old program that relies on the old semantics, you can
892 quickly fix the problem by changing signal() to sysv_signal() throughout.
893 Alternatively, define _XOPEN_SOURCE before including <signal.h>.
895 For new programs, the sigaction() function allows you to specify precisely
896 how you want your signals to behave.  All three differences listed above are
897 individually switchable on a per-signal basis with this function.
899 If all you want is for one specific signal to cause system calls to fail
900 and return EINTR (for example, to implement a timeout) you can do this with
901 siginterrupt().
904 3.8.    I've got errors compiling code that uses certain string
905         functions.  Why?
907 {AJ} glibc 2.1 has special string functions that are faster
908 than the normal library functions. Some of the functions are
909 implemented as inline functions and others as macros.
911 The optimized string functions are only used when compiling with
912 optimizations (-O1 or higher). The behavior can be changed with two
913 feature macros:
915 * __NO_STRING_INLINES: Don't do any string optimizations.
916 * __USE_STRING_INLINES: Use assembly language inline functions (might
917   increase code size dramatically).
919 Since some of these string functions are now additionally defined as
920 macros, code like "char *strncpy();" doesn't work anymore (and is
921 unnecessary, since <string.h> has the necessary declarations). Either
922 change your code or define __NO_STRING_INLINES.
924 {UD} Another problem in this area is that gcc still has problems on
925 machines with very few registers (e.g., ix86).  The inline assembler
926 code can require almost all the registers and the register allocator
927 cannot always handle this situation.
929 One can disable the string optimizations selectively.  Instead of writing
931         cp = strcpy (foo, "lkj");
933 one can write
935         cp = (strcpy) (foo, "lkj");
937 This disables the optimization for that specific call.
940 3.9.    I get compiler messages "Initializer element not constant" with
941         stdin/stdout/stderr. Why?
943 {RM,AJ} Constructs like:
944 static FILE *InPtr = stdin;
946 lead to this message. This is correct behaviour with glibc since stdin
947 is not a constant expression. Please note that a strict reading of ISO
948 C does not allow above constructs.
950 One of the advantages of this is that you can assign to stdin, stdout,
951 and stderr just like any other global variable (e.g. `stdout =
952 my_stream;'), which can be very useful with custom streams that you
953 can write with libio (but beware this is not necessarily
954 portable). The reason to implement it this way were versioning
955 problems with the size of the FILE structure.
958 3.10.   I can't compile with gcc -traditional (or
959         -traditional-cpp). Why?
961 {AJ} glibc2 does break -traditional and -traditonal-cpp - and will continue
962 to do so. For example constructs of the form:
963 enum {foo
964 #define foo foo
966 are  useful for debugging purpuses (you can use foo with your debugger
967 that's why we need the enum) and for compatibility (other systems use
968 defines and check with #ifdef).
971 3.11.   I get some errors with `gcc -ansi'. Isn't glibc ANSI compatible?
973 {AJ} The GNU C library is compatible with the ANSI/ISO C standard.  If
974 you're using `gcc -ansi', the glibc includes which are specified in
975 the standard follow the standard. The ANSI/ISO C standard defines what
976 has to be in the include files - and also states that nothing else
977 should be in the include files (btw. you can still enable additional
978 standards with feature flags).
980 The GNU C library is conforming to ANSI/ISO C - if and only if you're
981 only using the headers and library functions defined in the standard.
984 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
986 4. Miscellaneous
988 4.1.    After I changed configure.in I get `Autoconf version X.Y.
989         or higher is required for this script'.  What can I do?
991 {UD} You have to get the specified autoconf version (or a later one)
992 from your favorite mirror of prep.ai.mit.edu.
995 4.2.    When I try to compile code which uses IPv6 headers and
996         definitions on my Linux 2.x.y system I am in trouble.
997         Nothing seems to work.
999 {UD} The problem is that IPv6 development still has not reached a
1000 point where the headers are stable.  There are still lots of
1001 incompatible changes made and the libc headers have to follow.
1003 Also, make sure you have a suitably recent kernel.  As of the 970401
1004 snapshot, according to Philip Blundell <Philip.Blundell@pobox.com>, the
1005 required kernel version is at least 2.1.30.
1008 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
1010 Answers were given by:
1011 {UD} Ulrich Drepper, <drepper@cygnus.com>
1012 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
1013 {RM} Roland McGrath, <roland@gnu.org>
1014 {AJ} Andreas Jaeger, <aj@arthur.rhein-neckar.de>
1015 {EY} Eric Youngdale, <eric@andante.jic.com>
1016 {PB} Phil Blundell, <Philip.Blundell@pobox.com>
1017 {MK} Mark Kettenis, <kettenis@phys.uva.nl>
1018 {ZW} Zack Weinberg, <zack@rabi.phys.columbia.edu>
1019 {TK} Thorsten Kukuk, <kukuk@vt.uni-paderborn.de>
1020 {GK} Geoffrey Keating, <Geoff.Keating@anu.edu.au>
1022 Local Variables:
1023  mode:outline
1024  outline-regexp:"\\?"
1025 End: