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