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 package. 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?''
42 [Q10] ``Where are the DST_* constants found in <sys/time.h> on many
46 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
47 [Q1] ``What systems does the GNU C Library run on?''
49 [A1] {UD} This is difficult to answer. The file `README' lists the
50 architectures GNU libc is known to run *at some time*. This does not
51 mean that it still can be compiled and run on them in the moment.
53 The systems glibc is known to work on in the moment and most probably
57 i[3456]86-*-linux Linux-2.0 on Intel
58 m68k-*-linux Linux-2.0 on Motorola 680x0
59 alpha-*-linux Linux-2.0 on DEC Alpha
61 Other Linux platforms are also on the way to be supported but I need
62 some success reports first.
64 If you have a system not listed above (or in the `README' file) and
65 you are really interested in porting it, contact
67 <bug-glibc@prep.ai.mit.edu>
70 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
71 [Q2] ``What compiler do I need to build GNU libc?''
73 [A2] {UD} It is (almost) impossible to compile GNU C Library using a
74 different compiler than GNU CC. A lot of extensions of GNU CC are
75 used to increase the portability and speed.
77 But this does not mean you have to use GNU CC for using the GNU C
78 Library. In fact you should be able to use the native C compiler
79 because the success only depends on the binutils: the linker and
82 The GNU CC is found like all other GNU packages on
83 ftp://prep.ai.mit.edu/pub/gnu
84 or better one of the many mirror sites.
86 You always should try to use the latest official release. Older
87 versions might not have all the features GNU libc could use.
90 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
91 [Q3] ``When starting `make' I get only errors messages.
94 [A3] {UD} You definitely need GNU make to translate GNU libc. No
95 other make program has the needed functionality.
97 Versions before 3.74 have bugs which prevent correct execution so you
98 should upgrade to the latest version before starting the compilation.
101 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
102 [Q4] ``After I changed configure.in I get `Autoconf version X.Y.
103 or higher is required for this script'. What can I do?''
105 [A4] {UD} You have to get the specified autoconf version (or a later)
106 from your favourite mirror of prep.ai.mit.edu.
109 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
110 [Q5] ``Do I need a special linker or archiver?''
112 [A5] {UD} If your native versions are not too buggy you can probably
113 work with them. But GNU libc works best with GNU binutils.
115 On systems where the native linker does not support weak symbols you
116 will not get a really ISO C compliant C library. Generally speaking
117 you should use the GNU binutils if they provide at least the same
118 functionality as your system's tools.
120 Always get the newest release of GNU binutils available.
121 Older releases are known to have bugs that affect building the GNU C
125 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
126 [Q6] ``Do I need some more things to compile GNU C Library?''
128 [A6] {UD} Yes, there are some more :-).
130 * GNU gettext; the GNU libc is internationalized and partly localized.
131 For bringing the messages for the different languages in the needed
132 form the tools from the GNU gettext package are necessary. See
133 ftp://prep.ai.mit.edu/pub/gnu or better any mirror site.
135 * lots of diskspace (for i386-linux this means, e.g., ~70MB).
137 You should avoid compiling on a NFS mounted device. This is very
140 * plenty of time (approx 1h for i386-linux on i586@133 or 2.5h or
143 If you have some more measurements let me know.
145 * Some files depend on special tools. E.g., files ending in .gperf
146 need a `gperf' program. The GNU version (part of libg++) is known
147 to work while some vendor versions do not.
149 * When compiling for Linux:
151 + the header files of the Linux kernel must be available in the
152 search path of the CPP as <linux/*.h> and <asm/*.h>.
154 * Some files depend on special tools. E.g., files ending in .gperf
155 need a `gperf' program. The GNU version (part of libg++) is known
156 to work while some vendor versions do not.
158 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
159 [Q7] ``When I run `nm -u libc.so' on the produced library I still
160 find unresolved symbols? Can this be ok?''
162 [A7] {UD} Yes, this is ok. There can be several kinds of unresolved
165 * magic symbols automatically generated by the linker. Names are
166 often like __start_* and __stop_*
168 * symbols starting with _dl_* come from the dynamic linker
170 * symbols resolved by using libgcc.a
171 (__udivdi3, __umoddi3, or similar)
173 * weak symbols, which need not be resolved at all
174 (currently fabs among others; this gets resolved if the program
175 is linked against libm, too.)
177 Generally, you should make sure you find a real program which produces
178 errors while linking before deciding there is a problem.
181 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
182 [Q8] ``I expect GNU libc to be 100% source code compatible with
183 the old Linux based GNU libc. Why isn't it like this?''
185 [A8] {DMT,UD} Not every extension in Linux libc's history was well
186 thought-out. In fact it had a lot of problems with standards compliance
187 and with cleanliness. With the introduction of a new version number these
188 errors now can be corrected. Here is a list of the known source code
191 * _GNU_SOURCE: glibc does not automatically define _GNU_SOURCE. Thus,
192 if a program depends on GNU extensions or some other non-standard
193 functionality, it is necessary to compile it with C compiler option
194 -D_GNU_SOURCE, or better, to put `#define _GNU_SOURCE' at the beginning
195 of your source files, before any C library header files are included.
196 This difference normally manifests itself in the form of missing
197 prototypes and/or data type definitions. Thus, if you get such errors,
198 the first thing you should do is try defining _GNU_SOURCE and see if
199 that makes the problem go away.
201 For more information consult the file `NOTES' part of the GNU C
204 * reboot(): GNU libc sanitizes the interface of reboot() to be more
205 compatible with the interface used on other OSes. In particular,
206 reboot() as implemented in glibc takes just one argument. This argument
207 corresponds to the third argument of the Linux reboot system call.
208 That is, a call of the form reboot(a, b, c) needs to be changed into
210 Beside this the header <sys/reboot.h> defines the needed constants
211 for the argument. These RB_* constants should be used instead of the
212 cryptic magic numbers.
214 * swapon(): the interface of this function didn't changed, but the
215 prototype is in a separate header file <sys/swap.h>. For the additional
216 argument of of swapon() you should use the SWAP_* constants from
217 <linux/swap.h>, which get defined when <sys/swap.h> is included.
219 * errno: If a program uses variable "errno", then it _must_ include header
220 file <errno.h>. The old libc often (erroneously) declared this variable
221 implicitly as a side-effect of including other libc header files. glibc
222 is careful to avoid such namespace pollution, which, in turn, means that
223 you really need to include the header files that you depend on. This
224 difference normally manifests itself in the form of the compiler
225 complaining about the references of the undeclared symbol "errno".
227 * Linux-specific syscalls: All Linux system calls now have appropriate
228 library wrappers and corresponding declarations in various header files.
229 This is because the syscall() macro that was traditionally used to
230 work around missing syscall wrappers are inherently non-portable and
231 error-prone. The following tables lists all the new syscall stubs,
232 the header-file declaring their interface and the system call name.
234 syscall name: wrapper name: declaring header file:
235 ------------- ------------- ----------------------
236 bdflush bdflush <sys/kdaemon.h>
237 create_module create_module <sys/module.h>
238 delete_module delete_module <sys/module.h>
239 get_kernel_syms get_kernel_syms <sys/module.h>
240 init_module init_module <sys/module.h>
241 syslog ksyslog_ctl <sys/klog.h>
243 * lpd: Older versions of lpd depend on a routine called _validuser().
244 The library does not provide this function, but instead provides
245 __ivaliduser() which has a slightly different interfaces. Simply
246 upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
247 lpd is known to be working).
250 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
251 [Q9] ``Why does getlogin() always return NULL on my Linux box?''
253 [A9] {UD} The GNU C library has a format for the UTMP and WTMP file
254 which differs from what your system currently has. It was extended to
255 fulfill the needs of the next years when IPv6 is introduced. So the
256 record size is different, fields might have a different position and
257 so reading the files written by functions from the one library cannot
258 be read by functions from the other library. Sorry, but this is what
259 a major release is for. It's better to have a cut now than having no
260 means to support the new techniques later.
263 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
265 [Q10] ``Where are the DST_* constants found in <sys/time.h> on many
268 [A10] {UD} These constants come from the old BSD days and are not used
269 today anymore (even the Linux based glibc does not implement the handling
270 although the cosntants are defined).
272 Instead GNU libc contains the zone database handling and compatibility
273 code for POSIX TZ environment variable handling.
276 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
278 Answers were given by:
279 {UD} Ulrich Drepper, <drepper@cygnus.com>
280 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
283 {RM} Roland McGrath, <roland@gnu.ai.mit.edu>