1 Frequently Asked Question on GNU C Library
3 As every FAQ this one also tries to answer questions the user might have
4 when using the pacakge. Please make sure you read this before sending
5 questions or bug reports to the maintainers.
7 The GNU C Library is very complex. The building process exploits the
8 features available in tools generally available. But many things can
9 only be done using GNU tools. Also the code is sometimes hard to
10 understand because it has to be portable but on the other hand must be
11 fast. But you need not understand the details to use GNU C Library.
12 This will only be necessary if you intend to contribute or change it.
14 If you have any questions you think should be answered in this document,
19 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
20 [Q1] ``What systems does the GNU C Library run on?''
22 [Q2] ``What compiler do I need to build GNU libc?''
24 [Q3] ``When starting make I get only error messages.
27 [Q4] ``After I changed configure.in I get `Autoconf version X.Y.
28 or higher is required for this script'. What can I do?''
30 [Q5] ``Do I need a special linker or archiver?''
32 [Q6] ``Do I need some more things to compile GNU C Library?''
34 [Q7] ``When I run `nm -u libc.so' on the produced library I still
35 find unresolved symbols? Can this be ok?''
37 [Q8] ``I expect GNU libc to be 100% source code compatible with
38 the old Linux based GNU libc. Why isn't it like this?''
40 [Q9] ``Why does getlogin() always return NULL on my Linux box?''
43 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
44 [Q1] ``What systems does the GNU C Library run on?''
46 [A1] {UD} This is difficult to answer. The file `README' lists the
47 architectures GNU libc is known to run *at some time*. This does not
48 mean that it still can be compiled and run on them in the moment.
50 The systems glibc is known to work on in the moment and most probably
54 i[3456]86-*-linux Linux-2.0 on Intel
55 m68k-*-linux Linux-2.0 on Motorola 680x0
56 alpha-*-linux Linux-2.0 on DEC Alpha
58 Other Linux platforms are also on the way to be supported but I need
59 some success reports first.
61 If you have a system not listed above (or in the `README' file) and
62 you are really interested in porting it, contact
64 <bug-glibc@prep.ai.mit.edu>
67 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
68 [Q2] ``What compiler do I need to build GNU libc?''
70 [A2] {UD} It is (almost) impossible to compile GNU C Library using a
71 different compiler than GNU CC. A lot of extensions of GNU CC are
72 used to increase the portability and speed.
74 But this does not mean you have to use GNU CC for using the GNU C
75 Library. In fact you should be able to use the native C compiler
76 because the success only depends on the binutils: the linker and
79 The GNU CC is found like all other GNU packages on
80 ftp://prep.ai.mit.edu/pub/gnu
81 or better one of the many mirror sites.
83 You always should try to use the latest official release. Older
84 versions might not have all the features GNU libc could use.
87 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
88 [Q3] ``When starting `make' I get only errors messages.
91 [A3] {UD} You definitely need GNU make to translate GNU libc. No
92 other make program has the needed functionality.
94 Versions before 3.74 have bugs which prevent correct execution so you
95 should upgrade to the latest version before starting the compilation.
98 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
99 [Q4] ``After I changed configure.in I get `Autoconf version X.Y.
100 or higher is required for this script'. What can I do?''
102 [A4] {UD} You have to get the specified autoconf version (or a later)
103 from your favourite mirror of prep.ai.mit.edu.
106 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
107 [Q5] ``Do I need a special linker or archiver?''
109 [A5] {UD} If your native versions are not too buggy you can probably
110 work with them. But GNU libc works best with GNU binutils.
112 On systems where the native linker does not support weak symbols you
113 will not get a really ISO C compliant C library. Generally speaking
114 you should use the GNU binutils if they provide at least the same
115 functionality as your system's tools.
117 Always get the newest release of GNU binutils available.
118 Older releases are known to have bugs that affect building the GNU C
122 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
123 [Q6] ``Do I need some more things to compile GNU C Library?''
125 [A6] {UD} Yes, there are some more :-).
127 * GNU gettext; the GNU libc is internationalized and partly localized.
128 For bringing the messages for the different languages in the needed
129 form the tools from the GNU gettext package are necessary. See
130 ftp://prep.ai.mit.edu/pub/gnu or better any mirror site.
132 * lots of diskspace (for i386-linux this means, e.g., ~70MB).
134 You should avoid compiling on a NFS mounted device. This is very
137 * plenty of time (approx 1h for i386-linux on i586@133 or 2.5h or
140 If you have some more measurements let me know.
142 * Some files depend on special tools. E.g., files ending in .gperf
143 need a `gperf' program. The GNU version (part of libg++) is known
144 to work while some vendor versions do not.
146 * When compiling for Linux:
148 + the header files of the Linux kernel must be available in the
149 search path of the CPP as <linux/*.h> and <asm/*.h>.
151 * Some files depend on special tools. E.g., files ending in .gperf
152 need a `gperf' program. The GNU version (part of libg++) is known
153 to work while some vendor versions do not.
155 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
156 [Q7] ``When I run `nm -u libc.so' on the produced library I still
157 find unresolved symbols? Can this be ok?''
159 [A7] {UD} Yes, this is ok. There can be several kinds of unresolved
162 * magic symbols automatically generated by the linker. Names are
163 often like __start_* and __stop_*
165 * symbols starting with _dl_* come from the dynamic linker
167 * symbols resolved by using libgcc.a
168 (__udivdi3, __umoddi3, or similar)
170 * weak symbols, which need not be resolved at all
171 (currently fabs among others; this gets resolved if the program
172 is linked against libm, too.)
174 Generally, you should make sure you find a real program which produces
175 errors while linking before deciding there is a problem.
178 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
179 [Q8] ``I expect GNU libc to be 100% source code compatible with
180 the old Linux based GNU libc. Why isn't it like this?''
182 [A8] {DMT,UD} Not every extension in Linux libc's history was well
183 thought-out. In fact it had a lot of problems with standards compliance
184 and with cleanliness. With the introduction of a new version number these
185 errors now can be corrected. Here is a list of the known source code
188 * _GNU_SOURCE: glibc does not automatically define _GNU_SOURCE. Thus,
189 if a program depends on GNU extensions or some other non-standard
190 functionality, it is necessary to compile it with C compiler option
191 -D_GNU_SOURCE, or better, to put `#define _GNU_SOURCE' at the beginning
192 of your source files, before any C library header files are included.
193 This difference normally manifests itself in the form of missing
194 prototypes and/or data type definitions. Thus, if you get such errors,
195 the first thing you should do is try defining _GNU_SOURCE and see if
196 that makes the problem go away.
198 For more information consult the file `NOTES' part of the GNU C
201 * reboot(): GNU libc sanitizes the interface of reboot() to be more
202 compatible with the interface used on other OSes. In particular,
203 reboot() as implemented in glibc takes just one argument. This argument
204 corresponds to the third argument of the Linux reboot system call.
205 That is, a call of the form reboot(a, b, c) needs to be changed into
207 Beside this the header <sys/reboot.h> defines the needed constants
208 for the argument. These RB_* constants should be used instead of the
209 cryptic magic numbers.
211 * swapon(): the interface of this function didn't changed, but the
212 prototype is in a separate header file <sys/swap.h>. For the additional
213 argument of of swapon() you should use the SWAP_* constants from
214 <linux/swap.h>, which get defined when <sys/swap.h> is included.
216 * errno: If a program uses variable "errno", then it _must_ include header
217 file <errno.h>. The old libc often (erroneously) declared this variable
218 implicitly as a side-effect of including other libc header files. glibc
219 is careful to avoid such namespace pollution, which, in turn, means that
220 you really need to include the header files that you depend on. This
221 difference normally manifests itself in the form of the compiler
222 complaining about the references of the undeclared symbol "errno".
224 * Linux-specific syscalls: All Linux system calls now have appropriate
225 library wrappers and corresponding declarations in various header files.
226 This is because the syscall() macro that was traditionally used to
227 work around missing syscall wrappers are inherently non-portable and
228 error-prone. The following tables lists all the new syscall stubs,
229 the header-file declaring their interface and the system call name.
231 syscall name: wrapper name: declaring header file:
232 ------------- ------------- ----------------------
233 bdflush bdflush <sys/kdaemon.h>
234 create_module create_module <sys/module.h>
235 delete_module delete_module <sys/module.h>
236 get_kernel_syms get_kernel_syms <sys/module.h>
237 init_module init_module <sys/module.h>
238 syslog ksyslog_ctl <sys/klog.h>
240 * lpd: Older versions of lpd depend on a routine called _validuser().
241 The library does not provide this function, but instead provides
242 __ivaliduser() which has a slightly different interfaces. Simply
243 upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
244 lpd is known to be working).
247 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
248 [Q9] ``Why does getlogin() always return NULL on my Linux box?''
250 [A9] {UD} The GNU C library has a format for the UTMP and WTMP file
251 which differs from what your system currently has. It was extended to
252 fulfill the needs of the next years when IPv6 is introduced. So the
253 record size is different, fields might have a different position and
254 so reading the files written by functions from the one library cannot
255 be read by functions from the other library. Sorry, but this is what
256 a major release is for. It's better to have a cut now than having no
257 means to support the new techniques later.
260 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
263 Answers were given by:
264 {UD} Ulrich Drepper, <drepper@cygnus.com>
265 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
268 {RM} Roland McGrath, <roland@gnu.ai.mit.edu>