* posix/glob.h (__glob_opendir_hook, __glob_readdir_hook,
[glibc.git] / FAQ
blob8b676e6139eb61780ae410298f0f04433f4b193e
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,
15 please let me know.
17                                                   --drepper@cygnus.com
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.
25           What's wrong?''
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]    ``Can I replace the libc on my Linux system with GNU libc?''
39 [Q9]    ``I expect GNU libc to be 100% source code compatible with
40           the old Linux based GNU libc.  Why isn't it like this?''
42 [Q10]   ``Why does getlogin() always return NULL on my Linux box?''
44 [Q11]   ``Where are the DST_* constants found in <sys/time.h> on many
45           systems?''
47 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
48 [Q1]    ``What systems does the GNU C Library run on?''
50 [A1] {UD} This is difficult to answer.  The file `README' lists the
51 architectures GNU libc is known to run *at some time*.  This does not
52 mean that it still can be compiled and run on them in the moment.
54 The systems glibc is known to work on in the moment and most probably
55 in the future are:
57         *-*-gnu                 GNU Hurd
58         i[3456]86-*-linux       Linux-2.0 on Intel
59         m68k-*-linux            Linux-2.0 on Motorola 680x0
60         alpha-*-linux           Linux-2.0 on DEC Alpha
62 Other Linux platforms are also on the way to be supported but I need
63 some success reports first.
65 If you have a system not listed above (or in the `README' file) and
66 you are really interested in porting it, contact
68         <bug-glibc@prep.ai.mit.edu>
71 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
72 [Q2]    ``What compiler do I need to build GNU libc?''
74 [A2] {UD} It is (almost) impossible to compile GNU C Library using a
75 different compiler than GNU CC.  A lot of extensions of GNU CC are
76 used to increase the portability and speed.
78 But this does not mean you have to use GNU CC for using the GNU C
79 Library.  In fact you should be able to use the native C compiler
80 because the success only depends on the binutils: the linker and
81 archiver.
83 The GNU CC is found like all other GNU packages on
84         ftp://prep.ai.mit.edu/pub/gnu
85 or better one of the many mirror sites.
87 You always should try to use the latest official release.  Older
88 versions might not have all the features GNU libc could use.
91 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
92 [Q3]    ``When starting `make' I get only errors messages.
93           What's wrong?''
95 [A3] {UD} You definitely need GNU make to translate GNU libc.  No
96 other make program has the needed functionality.
98 Versions before 3.74 have bugs which prevent correct execution so you
99 should upgrade to the latest version before starting the compilation.
102 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
103 [Q4]    ``After I changed configure.in I get `Autoconf version X.Y.
104           or higher is required for this script'.  What can I do?''
106 [A4] {UD} You have to get the specified autoconf version (or a later)
107 from your favourite mirror of prep.ai.mit.edu.
110 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
111 [Q5]    ``Do I need a special linker or archiver?''
113 [A5] {UD} If your native versions are not too buggy you can probably
114 work with them.  But GNU libc works best with GNU binutils.
116 On systems where the native linker does not support weak symbols you
117 will not get a really ISO C compliant C library.  Generally speaking
118 you should use the GNU binutils if they provide at least the same
119 functionality as your system's tools.
121 Always get the newest release of GNU binutils available.
122 Older releases are known to have bugs that affect building the GNU C
123 Library.
126 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
127 [Q6]    ``Do I need some more things to compile GNU C Library?''
129 [A6] {UD} Yes, there are some more :-).
131 * GNU gettext; the GNU libc is internationalized and partly localized.
132   For bringing the messages for the different languages in the needed
133   form the tools from the GNU gettext package are necessary.  See
134   ftp://prep.ai.mit.edu/pub/gnu or better any mirror site.
136 * lots of diskspace (for i386-linux this means, e.g., ~70MB).
138   You should avoid compiling on a NFS mounted device.  This is very
139   slow.
141 * plenty of time (approx 1h for i386-linux on i586@133 or 2.5h on
142   i486@66 or 4.5h on i486@33).
144   If you have some more measurements let me know.
146 * Some files depend on special tools.  E.g., files ending in .gperf
147   need a `gperf' program.  The GNU version (part of libg++) is known
148   to work while some vendor versions do not.
150 * When compiling for Linux:
152   + the header files of the Linux kernel must be available in the
153     search path of the CPP as <linux/*.h> and <asm/*.h>.
155 * Some files depend on special tools.  E.g., files ending in .gperf
156   need a `gperf' program.  The GNU version (part of libg++) is known
157   to work while some vendor versions do not.
159 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
160 [Q7]    ``When I run `nm -u libc.so' on the produced library I still
161           find unresolved symbols?  Can this be ok?''
163 [A7] {UD} Yes, this is ok.  There can be several kinds of unresolved
164 symbols:
166 * magic symbols automatically generated by the linker.  Names are
167   often like __start_* and __stop_*
169 * symbols starting with _dl_* come from the dynamic linker
171 * symbols resolved by using libgcc.a
172   (__udivdi3, __umoddi3, or similar)
174 * weak symbols, which need not be resolved at all
175   (currently fabs among others; this gets resolved if the program
176    is linked against libm, too.)
178 Generally, you should make sure you find a real program which produces
179 errors while linking before deciding there is a problem.
182 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
183 [Q8]    ``Can I replace the libc on my Linux system with GNU libc?''
185 [A8] {UD} You cannot replace any existing libc for Linux with GNU
186 libc.  There are different versions of C libraries and you can run
187 libcs with different major version independently.
189 For Linux there are today two libc versions:
190         libc-4          old a.out libc
191         libc-5          current ELF libc
193 GNU libc will have the major number 6 and therefore you can have this
194 additionally installed.  For more information consult documenation for
195 shared library handling.  The Makefiles of GNU libc will automatically
196 generate the needed symbolic links which the linker will use.
199 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
200 [Q9]    ``I expect GNU libc to be 100% source code compatible with
201           the old Linux based GNU libc.  Why isn't it like this?''
203 [A9] {DMT,UD} Not every extension in Linux libc's history was well
204 thought-out.  In fact it had a lot of problems with standards compliance
205 and with cleanliness.  With the introduction of a new version number these
206 errors now can be corrected.  Here is a list of the known source code
207 incompatibilities:
209 * _GNU_SOURCE: glibc does not automatically define _GNU_SOURCE.  Thus,
210   if a program depends on GNU extensions or some other non-standard
211   functionality, it is necessary to compile it with C compiler option
212   -D_GNU_SOURCE, or better, to put `#define _GNU_SOURCE' at the beginning
213   of your source files, before any C library header files are included.
214   This difference normally manifests itself in the form of missing
215   prototypes and/or data type definitions.  Thus, if you get such errors,
216   the first thing you should do is try defining _GNU_SOURCE and see if
217   that makes the problem go away.
219   For more information consult the file `NOTES' part of the GNU C
220   library sources.
222 * reboot(): GNU libc sanitizes the interface of reboot() to be more
223   compatible with the interface used on other OSes.  In particular,
224   reboot() as implemented in glibc takes just one argument.  This argument
225   corresponds to the third argument of the Linux reboot system call.
226   That is, a call of the form reboot(a, b, c) needs to be changed into
227   reboot(c).
228      Beside this the header <sys/reboot.h> defines the needed constants
229   for the argument.  These RB_* constants should be used instead of the
230   cryptic magic numbers.
232 * swapon(): the interface of this function didn't changed, but the
233   prototype is in a separate header file <sys/swap.h>.  For the additional
234   argument of of swapon() you should use the SWAP_* constants from
235   <linux/swap.h>, which get defined when <sys/swap.h> is included.
237 * errno: If a program uses variable "errno", then it _must_ include header
238   file <errno.h>.  The old libc often (erroneously) declared this variable
239   implicitly as a side-effect of including other libc header files.  glibc
240   is careful to avoid such namespace pollution, which, in turn, means that
241   you really need to include the header files that you depend on.  This
242   difference normally manifests itself in the form of the compiler
243   complaining about the references of the undeclared symbol "errno".
245 * Linux-specific syscalls: All Linux system calls now have appropriate
246   library wrappers and corresponding declarations in various header files.
247   This is because the syscall() macro that was traditionally used to
248   work around missing syscall wrappers are inherently non-portable and
249   error-prone.  The following tables lists all the new syscall stubs,
250   the header-file declaring their interface and the system call name.
252        syscall name:    wrapper name:   declaring header file:
253        -------------    -------------   ----------------------
254        bdflush          bdflush         <sys/kdaemon.h>
255        create_module    create_module   <sys/module.h>
256        delete_module    delete_module   <sys/module.h>
257        get_kernel_syms  get_kernel_syms <sys/module.h>
258        init_module      init_module     <sys/module.h>
259        syslog           ksyslog_ctl     <sys/klog.h>
261 * lpd: Older versions of lpd depend on a routine called _validuser().
262   The library does not provide this function, but instead provides
263   __ivaliduser() which has a slightly different interfaces.  Simply
264   upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
265   lpd is known to be working).
267 * resolver functions/BIND: like on many other systems the functions of
268   the resolver library are not included in the libc itself.  There is
269   a separate library libresolv.  If you find some symbols starting with
270   `res_*' undefined simply add -lresolv to your call of the linker.
273 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
274 [Q10]   ``Why does getlogin() always return NULL on my Linux box?''
276 [A10] {UD} The GNU C library has a format for the UTMP and WTMP file
277 which differs from what your system currently has.  It was extended to
278 fulfill the needs of the next years when IPv6 is introduced.  So the
279 record size is different, fields might have a different position and
280 so reading the files written by functions from the one library cannot
281 be read by functions from the other library.  Sorry, but this is what
282 a major release is for.  It's better to have a cut now than having no
283 means to support the new techniques later.
286 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
288 [Q11]   ``Where are the DST_* constants found in <sys/time.h> on many
289           systems?''
291 [A11] {UD} These constants come from the old BSD days and are not used
292 today anymore (even the Linux based glibc does not implement the handling
293 although the constants are defined).
295 Instead GNU libc contains the zone database handling and compatibility
296 code for POSIX TZ environment variable handling.
299 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
301 Answers were given by:
302 {UD} Ulrich Drepper, <drepper@cygnus.com>
303 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
305 Amended by:
306 {RM} Roland McGrath, <roland@gnu.ai.mit.edu>
308 Local Variables:
309  mode:text
310 End: