tentative fix for issue 3 (ex 53)
[mplib] / src / texk / kpathsea / bugs.texi
1 @ifclear version
2 @defcodeindex fl
3 @defcodeindex op
4 @end ifclear
5
6 @node Reporting bugs
7 @section Reporting bugs
8
9 @cindex reporting bugs
10 @cindex bugs, reporting
11
12 @ifset version
13 (A copy of this chapter is in the file @file{kpathsea/BUGS}.)
14 @end ifset
15
16 @flindex tex-k@@mail.tug.org @r{(bug address)}
17 @cindex bug address
18 If you have problems or suggestions, please report them to
19 @email{tex-k@@mail.tug.org} using the bug checklist below.
20
21 Please report bugs in the documentation; not only factual errors or
22 inconsistent behavior, but unclear or incomplete explanations, typos,
23 wrong fonts, @dots{}
24
25 @menu
26 * Bug checklist::       What to include in a good bug report.
27 * Mailing lists::       Joining the bugs or announcements mailing lists.
28 * Debugging::           Analyzing runtime problems.
29 * Logging::             Recording searches.
30 * Common problems::     When things go wrong.
31 @end menu
32
33
34 @node Bug checklist
35 @subsection Bug checklist
36
37 @cindex checklist for bug reports
38 @cindex bug checklist
39
40 Before reporting a bug, please check below to be sure it isn't already
41 known (@pxref{Common problems}).
42
43 Bug reports should be sent via electronic mail to
44 @email{tex-k@@mail.tug.org}.
45
46 The general principle is that a good bug report includes all the
47 information necessary for reproduction.  Therefore, to enable
48 investigation, your report should include the following:
49
50 @itemize @bullet
51 @item
52 @cindex version numbers, determining
53 The version number(s) of the program(s) involved, and of Kpathsea
54 itself.  You can get the former by giving a sole option @samp{--version}
55 to the program, and the latter by running @samp{kpsewhich --version}.
56 The @file{NEWS} and @file{ChangeLog} files also contain the version
57 number.
58
59 @item
60 @pindex uname
61 The hardware, operating system (including version number), compiler, and
62 @code{make} program you are using (the output of @code{uname -a} is a
63 start on the first two, though often incomplete).  If the bug involves
64 the X window system, include X version and supplier information as well
65 (examples: X11R6 from MIT; X11R4 from HP; OpenWindows 3.3 bundled with
66 SunOS 4.1.4).
67
68 @item
69 @flindex config.log
70 Any options you gave to @code{configure}.  This is recorded in the
71 @file{config.status} files.
72
73 @cindex configuration bugs
74 @flindex config.status
75 If you are reporting a bug in @samp{configure} itself, it's probably
76 system-dependent, and it will be unlikely the maintainers can do
77 anything useful if you merely report that thus-and-such is broken.
78 Therefore, you need to do some additional work: for some bugs, you can
79 look in the file @file{config.log} where the test that failed should
80 appear, along with the compiler invocation and source program in
81 question.  You can then compile it yourself by hand, and discover why
82 the test failed.  Other @samp{configure} bugs do not involve the
83 compiler; in that case, the only recourse is to inspect the
84 @code{configure} shell script itself, or the Autoconf macros that
85 generated @code{configure}.
86
87 @item
88 The log of all debugging output, if the bug is in path searching.  You
89 can get this by setting the environment variable @code{KPATHSEA_DEBUG}
90 to @samp{-1} before running the program.  Please look at the log
91 yourself to make sure the behavior is really a bug before reporting it;
92 perhaps ``old'' environment variable settings are causing files not to
93 be found, for example.
94
95 @item
96 The contents of any input files necessary to reproduce the bug.  For
97 bugs in DVI-reading programs, for example, this generally means a DVI
98 file (and any EPS or other files it uses)---@TeX{} source files are
99 helpful, but the DVI file is necessary, because that's the actual
100 program input.
101
102 @item
103 @cindex context diff
104 @cindex sending patches
105 @flindex ChangeLog @r{entry}
106 If you are sending a patch (do so if you can!), please do so in the form
107 of a context diff (@samp{diff -c}) against the original distribution
108 source.  Any other form of diff is either not as complete or harder for
109 me to understand.  Please also include a @file{ChangeLog} entry.
110
111 @item
112 @cindex stack trace
113 @cindex debugger
114 @cindex crashes, reporting
115 @cindex core dumps, reporting
116 @cindex null pointers, dereferencing
117 @pindex gdb@r{, recommended}
118 If the bug involved is an actual crash (i.e., core dump), it is easy and
119 useful to include a stack trace from a debugger (I recommend the GNU
120 debugger GDB, available from @url{ftp://prep.ai.mit.edu/pub/gnu}).  If
121 the cause is apparent (a @code{NULL} value being dereferenced, for
122 example), please send the details along.  If the program involved is
123 @TeX{} or Metafont, and the crash is happening at apparently-sound code,
124 however, the bug may well be in the compiler, rather than in the program
125 or the library (@pxref{TeX or Metafont failing,, @TeX{} or Metafont
126 failing}).
127
128 @item
129 Any additional information that will be helpful in reproducing,
130 diagnosing, or fixing the bug.
131 @end itemize
132
133
134 @node Mailing lists
135 @subsection Mailing lists
136
137 @cindex mailing lists
138 @cindex bug mailing list
139 @cindex announcement mailing list
140
141 Web2c and Kpathsea in general are discussed on the mailing list
142 @email{tex-k@@mail.tug.org}.
143 @flindex tex-k-request@@mail.tug.org
144 To join, email @email{tex-k-request@@mail.tug.org} with a line
145 consisting of
146
147 @example
148 subscribe @var{you}@@@var{your.preferred.email.address}
149 @end example
150
151 @noindent in the body of the message.
152
153 You do not need to join to submit a report, nor will it affect whether
154 you get a response.  There is no Usenet newsgroup equivalent (if you can
155 be the one to set this up, email @samp{tex-k-request}).  Traffic on the
156 list is fairly light, and is mainly bug reports and enhancement requests
157 to the software.  The best way to decide if you want to join or not is
158 read some of the archives from @url{ftp://ftp.tug.org/mail/archives/tex-k/}.
159
160 Be aware that large data files are sometimes included in bug reports.
161 If this is a problem for you, do not join the list.
162
163 @flindex tex-archive@@math.utah.edu
164 @cindex announcement mailing list
165 If you only want announcements of new releases, not bug reports and
166 discussion, join @email{tex-archive@@math.utah.edu} (via mail to
167 @email{tex-archive-request@@math.utah.edu}).
168
169 @cindex @TeX{} help mailing list
170 @cindex La@TeX{} help mailing list
171 @cindex Usenet @TeX{} newsgroup
172 @cindex newsgroup for @TeX{}
173 @cindex help, mailing list for general @TeX{}
174 @flindex info-tex@@shsu.edu
175 @flindex comp.text.tex
176 If you are looking for general @TeX{} help, such as how to use La@TeX{},
177 please use the mailing list @email{info-tex@@shsu.edu} mailing list,
178 which is gatewayed to the @samp{comp.text.tex} Usenet newsgroup (or post
179 to the newsgroup; the gateway is bidirectional).
180
181
182 @node Debugging
183 @subsection Debugging
184
185 @cindex debugging
186 @cindex runtime debugging
187 @cindex options for debugging
188
189 @vindex kpathsea_debug
190 @flindex debug.h
191 Kpathsea provides a number of runtime debugging options, detailed below
192 by their names and corresponding numeric values.  When the files you
193 expect aren't being found, the thing to do is enable these options and
194 examine the output.
195
196 You can set these with some runtime argument (e.g., @samp{-d}) to the
197 program; in that case, you should use the numeric values described in
198 the program's documentation (which, for Dvipsk and Xdvik, are different
199 than those below).  It's best to give the @samp{-d} (or whatever) option
200 first, for maximal output.  Dvipsk and Xdvik have additional
201 program-specific debugging options as well.
202
203 @vindex KPATHSEA_DEBUG
204 @vindex kpathsea_debug
205 You can also set the environment variable @code{KPATHSEA_DEBUG}; in this
206 case, you should use the numbers below.  If you run the program under a
207 debugger and set the variable @code{kpathsea_debug}, also use the numbers
208 below.
209
210 @kindex -1 @r{debugging value}
211 In any case, by far the simplest value to use is @samp{-1}, which will
212 turn on all debugging output.  This is usually better than guessing
213 which particular values will yield the output you need.
214
215 @cindex debugging output
216 @cindex standard error and debugging output
217 Debugging output always goes to standard error, so you can redirect it
218 easily.  For example, in Bourne-compatible shells:
219 @example
220 dvips -d -1 @dots{} 2>/tmp/debug
221 @end example
222
223 @cindex Kpsewhich, and debugging
224 It is sometimes helpful to run the standalone Kpsewhich utility
225 (@pxref{Invoking kpsewhich}), instead of the original program.
226
227 @cindex numeric debugging values
228 In any case, you can @emph{not} use the @emph{names} below; you must
229 always use somebody's numbers.  (Sorry.)  To set more than one
230 option, just sum the corresponding numbers.
231
232 @vtable @code
233 @item KPSE_DEBUG_STAT @r{(1)}
234 Report @samp{stat}(2) calls. This is useful for verifying that your
235 directory structure is not forcing Kpathsea to do many additional file
236 tests (@pxref{Slow path searching}, and @pxref{Subdirectory
237 expansion}). If you are using an up-to-date @file{ls-R} database
238 (@pxref{Filename database}), this should produce no output unless a
239 nonexistent file that must exist is searched for.
240
241 @item KPSE_DEBUG_HASH @r{(2)}
242 Report lookups in all hash tables: @file{ls-R} and @file{aliases}
243 (@pxref{Filename database}); font aliases (@pxref{Fontmap}); and config
244 file values (@pxref{Config files}).  Useful when expected values are not
245 being found, e.g.., file searches are looking at the disk instead of
246 using @file{ls-R}.
247
248 @item KPSE_DEBUG_FOPEN @r{(4)}
249 @findex fopen@r{, redefined}
250 Report file openings and closings. Especially useful when your system's
251 file table is full, for seeing which files have been opened but never
252 closed. In case you want to set breakpoints in a debugger: this works by
253 redefining @samp{fopen} (@samp{fclose}) to be @samp{kpse_fopen_trace}
254 (@samp{kpse_fclose_trace}).
255
256 @item KPSE_DEBUG_PATHS @r{(8)}
257 @tindex kpse_format_info_type
258 Report general path information for each file type Kpathsea is asked to
259 search. This is useful when you are trying to track down how a
260 particular path got defined---from @file{texmf.cnf}, @file{config.ps},
261 an environment variable, the compile-time default, etc.  This is the
262 contents of the @code{kpse_format_info_type} structure defined in
263 @file{tex-file.h}.
264
265 @item KPSE_DEBUG_EXPAND @r{(16)}
266 Report the directory list corresponding to each path element Kpathsea
267 searches. This is only relevant when Kpathsea searches the disk, since
268 @file{ls-R} searches don't look through directory lists in this way.
269
270 @item KPSE_DEBUG_SEARCH @r{(32)}
271 Report on each file search: the name of the file searched for, the path
272 searched in, whether or not the file must exist (when drivers search for
273 @file{cmr10.vf}, it need not exist), and whether or not we are
274 collecting all occurrences of the file in the path (as with, e.g.,
275 @file{texmf.cnf} and @file{texfonts.map}), or just the first (as with
276 most lookups).  This can help you correlate what Kpathsea is doing with
277 what is in your input file.
278
279 @item KPSE_DEBUG_VARS @r{(64)}
280 Report the value of each variable Kpathsea looks up.  This is useful for
281 verifying that variables do indeed obtain their correct values.
282
283 @item GSFTOPK_DEBUG @r{(128)}
284 Activates debugging printout specific to @code{gsftopk} program.
285
286 @item MAKETEX_DEBUG @r{(512)}
287 If you use the optional @code{mktex} programs instead of the
288 traditional shell scripts, this will report the name of the site file
289 (@file{mktex.cnf} by default) which is read, directories created by
290 @code{mktexdir}, the full path of the @file{ls-R} database built by
291 @code{mktexlsr}, font map searches, @code{MT_FEATURES} in effect,
292 parameters from @code{mktexnam}, filenames added by
293 @code{mktexupd}, and some subsidiary commands run by the programs.
294
295 @item MAKETEX_FINE_DEBUG @r{(1024)}
296 When the optional @code{mktex} programs are used, this will print
297 additional debugging info from functions internal to these programs.
298 @end vtable
299
300 @cindex @samp{kdebug:}
301 @vindex hash_summary_only @r{variable for debugging}
302 @cindex hash table buckets, printing
303 Debugging output from Kpathsea is always written to standard error, and
304 begins with the string @samp{kdebug:}. (Except for hash table buckets,
305 which just start with the number, but you can only get that output
306 running under a debugger. See comments at the @code{hash_summary_only}
307 variable in @file{kpathsea/db.c}.)
308
309
310 @node Logging
311 @subsection Logging
312
313 @cindex log file
314
315 @cindex logging successful searches
316 @cindex recording successful searches
317 @cindex usage patterns, finding
318 @cindex disk usage, reducing
319 Kpathsea can record the time and filename found for each successful
320 search.  This may be useful in finding good candidates for deletion when
321 your filesystem is full, or in discovering usage patterns
322 at your site.
323
324 @vindex TEXMFLOG
325 To do this, define the environment or config file variable
326 @code{TEXMFLOG}.  The value is the name of the file to append the
327 information to.  The file is created if it doesn't exist, and appended
328 to if it does.
329
330 @cindex epoch, seconds since
331 @findex time @r{system call}
332 Each successful search turns into one line in the log file: two words
333 separated by a space. The first word is the time of the search, as the
334 integer number of seconds since ``the epoch'', i.e., UTC midnight 1
335 January 1970 (more precisely, the result of the @code{time} system
336 call). The second word is the filename.
337
338 For example, after @code{setenv TEXMFLOG /tmp/log}, running Dvips on
339 @file{story.dvi} appends the following lines:
340
341 @example
342 774455887 /usr/local/share/texmf/dvips/config.ps
343 774455887 /usr/local/share/texmf/dvips/psfonts.map
344 774455888 /usr/local/share/texmf/dvips/texc.pro
345 774455888 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmbx10.600pk
346 774455889 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmsl10.600pk
347 774455889 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmr10.600pk
348 774455889 /usr/local/share/texmf/dvips/texc.pro
349 @end example
350
351 @cindex privacy, semblance of
352 @noindent Only filenames that are absolute are recorded, to preserve
353 some semblance of privacy.
354
355 In addition to this Kpathsea-specific logging, @command{pdftex}
356 provides an option @option{-recorder} to write the names of all files
357 accessed during a run to the file @file{@var{basefile}.fls}.
358
359 Finally, most systems provide a general tool to output each system
360 call, thus including opening and closing files.  It might be named
361 @command{strace}, @command{truss}, @command{struss}, or something
362 else.
363
364
365 @node Common problems
366 @subsection Common problems
367
368 @cindex common problems
369 @cindex problems, common
370 @cindex FAQ, Kpathsea
371
372 Here are some common problems with configuration, compilation, linking,
373 execution, @dots{}
374
375 @menu
376 * Unable to find files::        If your program can't find fonts (or whatever).
377 * Slow path searching::         If it takes forever to find anything.
378 * Unable to generate fonts::    If mktexpk fails.
379 * TeX or Metafont failing::     Likely compiler bugs.
380
381 * Empty Makefiles::             When configure produces empty makefiles.
382 * XtStrings::                   When _XtStrings is undefined.
383 * dlopen::                      When dlopen is undefined.
384 * ShellWidgetClass::            For dynamic linking troubles under OpenWindows.
385 * Pointer combination warnings::  For old compilers that don't grok char *.
386 @end menu
387
388 @node Unable to find files
389 @subsubsection Unable to find files
390
391 @cindex unable to find files
392 @cindex files, unable to find
393
394 If a program complains it cannot find fonts (or other input files), any
395 of several things might be wrong.  In any case, you may find the
396 debugging options helpful.  @xref{Debugging}.
397
398 @itemize @bullet
399 @item
400 Perhaps you simply haven't installed all the necessary files; the basic
401 fonts and input files are distributed separately from the programs.
402 @xref{unixtex.ftp}.
403
404 @item
405 @flindex /etc/profile
406 @cindex environment variables, old
407 You have (perhaps unknowingly) told Kpathsea to use search paths that
408 don't reflect where the files actually are.  One common cause is having
409 environment variables set from a previous installation, thus overriding
410 what you carefully set in @file{texmf.cnf} (@pxref{Supported file
411 formats}).  System @file{/etc/profile} or other files such may be the
412 culprit.
413
414 @item
415 @cindex symbolic links not found
416 @cindex leaf directories wrongly guessed
417 Your files reside in a directory that is only pointed to via a symbolic
418 link, in a leaf directory and is not listed in @file{ls-R}.
419
420 Unfortunately, Kpathsea's subdirectory searching has an irremediable
421 deficiency: If a directory @var{d} being searched for subdirectories
422 contains plain files and symbolic links to other directories, but no
423 true subdirectories, @var{d} will be considered a leaf directory, i.e.,
424 the symbolic links will not be followed.  @xref{Subdirectory expansion}.
425
426 You can work around this problem by creating an empty dummy subdirectory
427 in @var{d}. Then @var{d} will no longer be a leaf, and the symlinks will
428 be followed.
429
430 The directory immediately followed by the @samp{//} in the path
431 specification, however, is always searched for subdirectories, even if
432 it is a leaf.  Presumably you would not have asked for the directory to
433 be searched for subdirectories if you didn't want it to be.
434
435 @item
436 If the fonts (or whatever) don't already exist, @code{mktexpk} (or
437 @code{mktexmf} or @code{mktextfm}) will try to create them.  If
438 these rather complicated shell scripts fail, you'll eventually get an
439 error message saying something like @samp{Can't find font
440 @var{fontname}}. The best solution is to fix (or at least report) the
441 bug in @code{mktexpk}; the workaround is to generate the necessary
442 fonts by hand with Metafont, or to grab them from a CTAN site
443 (@pxref{unixtex.ftp}).
444
445 @item
446 There is a bug in the library. @xref{Reporting bugs}.
447 @end itemize
448
449
450 @node Slow path searching
451 @subsubsection Slow path searching
452
453 @cindex excessive startup time
454 @cindex slow startup time
455 @cindex startup time, excessive
456
457 If your program takes an excessively long time to find fonts or other
458 input files, but does eventually succeed, here are some possible culprits:
459
460 @itemize @bullet
461 @item
462 Most likely, you just have a lot of directories to search, and that
463 takes a noticeable time. The solution is to create and maintain a
464 separate @file{ls-R} file that lists all the files in your main @TeX{}
465 hierarchy.  @xref{Filename database}.  Kpathsea always uses @file{ls-R}
466 if it's present; there's no need to recompile or reconfigure any of the
467 programs.
468
469 @item
470 Your recursively-searched directories (e.g.,
471 @file{/usr/local/share/texmf/fonts//}), contain a mixture of files and
472 directories. This prevents Kpathsea from using a useful optimization
473 (@pxref{Subdirectory expansion}).
474
475 It is best to have only directories (and perhaps a @file{README}) in the
476 upper levels of the directory structure, and it's very important to have
477 @emph{only} files, and no subdirectories, in the leaf directories where
478 the dozens of TFM, PK, or whatever files reside.
479 @end itemize
480
481 In any case, you may find the debugging options helpful in determining
482 precisely when the disk or network is being pounded.  @xref{Debugging}.
483
484
485 @node Unable to generate fonts
486 @subsubsection Unable to generate fonts
487
488 @cindex unable to generate fonts
489 @cindex font generation failures
490
491 Metafont outputs fonts in bitmap format, tuned for a particular
492 device at a particular resolution, in order to allow for the
493 highest-possible quality of output.  Some DVI-to-whatever programs,
494 such as Dvips, try to generate these on the fly when they are needed,
495 but this generation may fail in several cases.
496
497 @cindex @code{mktexpk} can't guess mode
498 If @code{mktexpk} runs, but fails with this error:
499 @example
500 mktexpk: Can't guess mode for @var{nnn} dpi devices.
501 mktexpk: Use a config file to specify the mode, or update me.
502 @end example
503 you need to ensure the resolution and mode match; just
504 specifying the resolution, as in @code{-D 360}, is not enough.
505
506 You can specify the mode name with the @code{-mode} option on the
507 Dvips command line, or in a Dvips configuration file (@pxref{Config
508 files,,, dvips, Dvips}), such as @file{config.ps} in your document
509 directory, @file{~/.dvipsrc} in your home directory, or in a system
510 directory (again named @file{config.ps}).  (Other drivers use other
511 files, naturally.)
512
513 For example, if you need 360@dmn{dpi} fonts, you could include this in
514 a configuration file:
515 @example
516 D 360
517 M lqmed
518 @end example
519
520 @cindex Metafont using the wrong device
521 @cindex device, wrong
522 If Metafont runs, but generates fonts at the wrong resolution or for
523 the wrong device, most likely @code{mktexpk}'s built-in guess for the
524 mode is wrong, and you should override it as above.
525
526 See @url{ftp://ftp.tug.org/tex/modes.mf} for a list of resolutions and
527 mode names for most devices (additional submissions are welcome).
528
529 @flindex .2602gf
530 @flindex 2602gf
531 @cindex Metafont making too-large fonts
532 @cindex proof mode
533 @cindex online Metafont display, spurious
534 If Metafont runs but generates fonts at a resolution of 2602@dmn{dpi}
535 (and prints out the name of each character as well as just a character
536 number, and maybe tries to display the characters), then your Metafont
537 base file probably hasn't been made properly.  (It's using the default
538 @code{proof} mode, instead of an actual device mode.)  To make a proper
539 @file{plain.base}, assuming the local mode definitions are contained in
540 a file @file{modes.mf}, run the following command (assuming Unix):
541
542 @example
543 inimf "plain; input modes; dump"
544 @end example
545
546 @noindent
547 @flindex plain.base
548 Then copy the @file{plain.base} file from the current directory to where
549 the base files are stored on your system
550 (@file{/usr/local/share/texmf/web2c} by default), and make a link
551 (either hard or soft) from @file{plain.base} to @file{mf.base} in that
552 directory.
553 @xref{inimf invocation,,, web2c, Web2c}.
554
555 @cindex Metafont installation
556 If @code{mf} is a command not found at all by @code{mktexpk}, then you
557 need to install Metafont (@pxref{unixtex.ftp}).
558
559
560 @node TeX or Metafont failing
561 @subsubsection @TeX{} or Metafont failing
562
563 @cindex @TeX{} failures
564 @cindex Metafont failures
565 @cindex compiler bugs
566 If @TeX{} or Metafont get a segmentation fault or otherwise fail while
567 running a normal input file, the problem is usually a compiler bug
568 (unlikely as that may sound).  Even if the trip and trap tests are
569 passed, problems may lurk.  Optimization occasionally causes trouble in
570 programs other than @TeX{} and Metafont themselves, too.
571
572 Insufficient swap space may also cause core dumps or other erratic
573 behavior.
574
575 @cindex optimization caveat
576 For a workaround, if you enabled any optimization flags, it's best to
577 omit optimization entirely.  In any case, the way to find the facts is
578 to run the program under the debugger and see where it's failing.
579
580 @cindex GNU C compiler bugs
581 @cindex system C compiler bugs
582 Also, if you have trouble with a system C compiler, I advise trying the
583 GNU C compiler. And vice versa, unfortunately; but in that case I also
584 recommend reporting a bug to the GCC mailing list; see @ref{Bugs,,, gcc,
585 Using and Porting GNU CC}.
586
587 @cindex compiler bugs, finding
588 To report compiler bugs effectively requires perseverance and
589 perspicacity: you must find the miscompiled line, and that usually
590 involves delving backwards in time from the point of error, checking
591 through @TeX{}'s (or whatever program's) data structures.  Things are
592 not helped by all-too-common bugs in the debugger itself.  Good luck.
593
594 @cindex ANSI C
595 @cindex HP-UX, compiling on
596 @cindex compiling on HP-UX
597 One known cause of trouble is the way arrays are handled.  Some of the
598 Pascal arrays have a lower index other than 0, and the C code will take
599 the pointer to the allocated memory, subtract the lower index, and use
600 the resulting pointer for the array.  While this trick often works, ANSI
601 C doesn't guarantee that it will.  It it known to fail on HP-UX 10
602 mchines when the native compiler is used, unless the @samp{+u} compiler
603 switch was specified.  Using GCC will work on this platform as well.
604
605 @node Empty Makefiles
606 @subsubsection Empty Makefiles
607
608 @cindex Makefiles, empty
609 @pindex sed @r{error from @code{configure}}
610 @pindex configure @r{error from @code{sed}}
611 @cindex NetBSD @code{configure} error
612 @cindex FreeBSD @code{configure} error
613 @cindex Mach10 @code{configure} error
614 @cindex AIX 4.1 @code{configure} error
615 @cindex NeXT @code{sed} error
616
617 On some systems (NetBSD, FreeBSD, AIX 4.1, and Mach10), @code{configure}
618 may fail to properly create the Makefiles. Instead, you get an error
619 which looks something like this:
620
621 @example
622 prompt$ ./configure
623 @dots{}
624 creating Makefile
625 sed: 1: "\\@@^ac_include make/pat ...": \ can not be used as a string delimiter
626 @end example
627
628 So far as I know, the bug here is in @code{/bin/sh} on these systems. I
629 don't have access to a machine running any of them, so if someone can
630 find a workaround that avoids the quoting bug, I'd be most
631 grateful. (Search for @code{ac_include} in the @code{configure} script
632 to get to the problematic code.)
633
634 It should work to run @code{bash configure}, instead of using
635 @code{/bin/sh}. You can get Bash from
636 @url{ftp://prep.ai.mit.edu/pub/gnu} and mirrors.
637
638 Another possible cause (reported for NeXT) is a bug in the @code{sed}
639 command.  In that case the error may look like this:
640
641 @example
642 Unrecognized command: \@@^ac_include make/paths.make@@r make/paths.make
643 @end example
644
645 In this case, installing GNU @code{sed} should solve the problem.  You
646 can get GNU @code{sed} from the same places as Bash.
647
648 @ignore
649 @node wchar_t
650 @subsubsection @code{wchar_t}
651
652 @vindex FOIL_X_WCHAR_T
653 @tindex wchar_t
654
655 The upshot of all the following is that if you get error messages
656 regarding @code{wchar_t}, try defining @code{NO_FOIL_X_WCHAR_T} (for
657 Web2c) or @code{FOIL_X_WCHAR_T} (for everything else), as in:
658
659 @example
660 make XCFLAGS=-DNO_FOIL_X_WCHAR_T @var{other-make-options}
661 @end example
662
663 @flindex Xlib.h
664 @flindex stddef.h
665 @code{wchar_t} has caused infinite trouble. None of my code ever uses
666 @code{wchar_t}; all I want to do is include X header files and various
667 system header files, possibly compiling with GCC. This seems an
668 impossible task! The basic problem is that the X11 header
669 @file{<Xlib.h>} and GCC's @file{<stddef.h>} have conflicting definitions
670 for @code{wchar_t}.
671
672 The particulars: @file{<X11/Xlib.h>} from MIT X11R5 defines
673 @code{wchar_t} if @code{X_WCHAR} is defined, which is defined if
674 @code{X_NOT_STDC_ENV} is defined, and we define @emph{that} if
675 @code{STDC_HEADERS} is not defined (@samp{configure} decides if
676 @code{STDC_HEADERS} gets defined).  But when compiling with GCC on SunOS
677 4.1.x, @code{STDC_HEADERS} is not defined (@file{string.h} doesn't
678 declare the @samp{mem}* functions), so we do get X's
679 @code{wchar_t}---and we also get GCC's @code{wchar_t} from its
680 @file{<stddef.h>}.  Conflict.
681
682 On the other hand, SunOS 4.1.1 with some other X configurations actually
683 needs GCC to define @code{wchar_t}, and fails otherwise.
684
685 My current theory is to define @code{wchar_t} to a nonsense symbol
686 before the X include files are read; that way its definition (if any)
687 will be ignored by other system include files.  Going along with that,
688 define @code{X_WCHAR} to tell X not to use @file{<stddef.h>}, that we've
689 already included, but instead to make its own definition.
690
691 But this is not the end of the story. The X11 include files distributed
692 with DG/UX 5.4.2 for the Aviion have been modified to include
693 @file{<_int_wchar_t.h>} if @code{X_WCHAR}, so our @code{#define} will
694 not have any typedef to change---but the uses of @code{wchar_t} in the X
695 include files will be changed to reference this undefined symbol. So
696 there's nothing to foil in this case. I don't know how to detect this
697 automatically, so it's up to you to define @code{NO_FOIL_X_WCHAR_T}
698 yourself.
699 @end ignore
700
701 @node XtStrings
702 @subsubsection @code{XtStrings}
703
704 @findex XtStrings
705 You may find that linking X programs results in an error from the linker
706 that @samp{XtStrings} is undefined, something like this:
707
708 @example
709 gcc -o virmf @dots{}
710 @dots{}/x11.c:130: undefined reference to `XtStrings'
711 @end example
712
713 This generally happens because of a mismatch between the X include files
714 with which you compiled and the X libraries with which you linked;
715 often, the include files are from MIT and the libraries from Sun.
716
717 The solution is to use the same X distribution for compilation and
718 linking.  Probably @samp{configure} was unable to guess the proper
719 directories from your installation.  You can use the @code{configure}
720 options @samp{--x-includes=@var{path}} and
721 @samp{--x-libraries=@var{path}} to explicitly specify them.
722
723
724 @node dlopen
725 @subsubsection @code{dlopen}
726
727 @cindex static linking and @code{dlsym}
728 @flindex dlopen
729 @flindex dlsym
730 @flindex dlclose
731 @flindex wcstombs
732 @flindex libdl.a
733 (This section adapted from the file @file{dlsym.c} in the X distribution.)
734
735 The @code{Xlib} library uses the standard C function @code{wcstombs}.
736 Under SunOS 4.1, @code{wcstombs} uses the @samp{dlsym} interface defined
737 in @file{libdl.so}.  Unfortunately, the SunOS 4.1 distribution does not
738 include a static @samp{libdl.a} library.
739
740 As a result, if you try to link an X program statically under SunOS, you
741 may get undefined references to @code{dlopen}, @code{dlsym}, and
742 @code{dlclose}.  One workaround is to include these definitions
743 when you link:
744
745 @example
746 void *dlopen() @{ return 0; @}
747 void *dlsym()  @{ return 0; @}
748 int dlclose()  @{ return -1; @}
749 @end example
750
751 @flindex dlsym.c
752 @noindent These are contained in the @file{dlsym.c} file in the MIT X
753 distribution.
754
755
756 @node ShellWidgetClass
757 @subsubsection @code{ShellWidgetClass}
758
759 @cindex dynamic linking problems with OpenWin libraries
760 @cindex OpenWin libraries, dynamic linking problems
761 @findex get_wmShellWidgetClass
762 @findex get_applicationShellWidgetClass
763
764 @flindex comp.sys.sun.admin @r{FAQ}
765 @cindex FAQ, @t{comp.sys.sun.admin}
766 (This section adapted from the @t{comp.sys.sun.admin} FAQ.)
767
768 If you are linking with Sun's OpenWindows libraries in SunOS 4.1.x, you
769 may get undefined symbols @code{_get_wmShellWidgetClass} and
770 @code{_get_applicationShellWidgetClass} when linking. This problem does
771 not arise using the standard MIT X libraries under SunOS.
772
773 @findex Xmu @r{library problems}
774 The cause is bugs in the @code{Xmu} shared library as shipped from Sun.
775 There are several fixes:
776
777 @itemize @bullet
778
779 @item Install the free MIT distribution from @samp{ftp.x.org} and mirrors.
780
781 @item Get the OpenWindows patches listed below.
782
783 @item Statically link the @code{Xmu} library into the executable.
784
785 @item Avoid using @code{Xmu} at all. If you are compiling
786 Metafont, see @ref{Online Metafont graphics,,, web2c, Web2c}. If you are
787 compiling Xdvi, see the @code{-DNOTOOL} option in @file{xdvik/INSTALL}.
788
789 @item Ignore the errors. The binary runs fine regardless.
790
791 @end itemize
792
793 @cindex Sun OpenWin patches
794 @cindex patches, Sun OpenWin
795 Here is the information for getting the two patches:
796
797 @display
798 Patch ID: 100512-02
799 Bug ID's: 1086793, 1086912, 1074766
800 Description: 4.1.x OpenWindows 3.0 @code{libXt} jumbo patch
801
802 Patch ID: 100573-03
803 Bug ID: 1087332
804 Description: 4.1.x OpenWindows 3.0 undefined symbols when using shared @code{libXmu}.
805 @end display
806
807 @cindex static linking
808 The way to statically link with @code{libXmu} depends on whether you are
809 using a Sun compiler (e.g., @code{cc}) or @code{gcc}. If the latter,
810 alter the @code{x_libs} Make variable to include
811
812 @opindex -static
813 @opindex -dynamic
814 @example
815 -static -lXmu -dynamic
816 @end example
817
818 @opindex -Bstatic
819 @opindex -Bdynamic
820 If you are using the Sun compiler, use @samp{-Bstatic} and @samp{-Bdynamic}.
821
822
823 @node Pointer combination warnings
824 @subsubsection Pointer combination warnings
825
826 @cindex warnings, pointer combinations
827 @cindex pointer combination warnings
828 @cindex illegal pointer combination warnings
829 @pindex cc @r{warnings}
830 When compiling with old C compilers, you may get some warnings about
831 ``illegal pointer combinations''.  These are spurious; just ignore them.
832 I decline to clutter up the source with casts to get rid of them.
833
834 @c This isn't worth including any more, OSF 1.x is too old.
835 @c The other XtInherit problem (R4 Xlib on Suns) should never come up,
836 @c but the answer from the X faq is included anyway.
837 @c
838 @c @node XtInherit
839 @c @subsubsection @code{XtInherit}
840 @c 
841 @c @findex XtInherit @r{bug on OSF/1}
842 @c @cindex OSF/1 loader bug and @code{XtInherit}
843 @c @cindex Alpha OSF/1 loader bug and @code{XtInherit}
844 @c 
845 @c On DEC OSF/1 1.x systems, the loader has a bug that manifests itself in
846 @c the following error (all on one line, but for the sake of the paper
847 @c width it's broken here):
848 @c 
849 @c @example
850 @c xdvik/xdvi: /sbin/loader: Fatal Error: search_for_undefineds: 
851 @c      symbol _XtInherit should not have any relocation entry
852 @c @end example
853 @c 
854 @c @noindent According to Michael Rickabaugh @code{<mjr@@quarry.enet.dec.com>}:
855 @c 
856 @c @quotation
857 @c This is a bug fixed in DEC OSF/1 2.0.
858 @c 
859 @c If you know how, installing @file{/sbin/loader} from a 2.0 system onto a
860 @c 1.3 system will work.  Make sure that @file{/usr} is @emph{not} mounted
861 @c when you do this.  (If you forget about umounting @code{/usr}, it is
862 @c possible most of your filesystems will become corrupted.)
863 @c 
864 @c Otherwise, I suggest getting a later CD and running
865 @c @file{/usr/sbin/installupdate}.
866 @c @end quotation
867 @c 
868 @c Alternatively, you may be able to use the freely available X11 libraries
869 @c that come with the MIT distribution (on @file{ftp.x.org}, for example).
870 @c 
871 @c Linking statically, perhaps only with some of the X libraries, may also
872 @c work.
873 @c 
874 @c The Sun XtInherit weirdness, from the comp.windows.x FAQ:
875 @c Subject: 126)! What are these problems with "*_XtInherit* not found" on the Sun?
876 @c When I link a X program that I wrote on a SunOS 4.0.3 or 4.1 machine I get the 
877 @c error "ld.so: symbol not found *_XtInherit*".
878 @c 
879 @c      What you are seeing is a side-effect of a kludge in the R4 libXt.a to 
880 @c get Sun shared libraries working.  Apparently, you can't share a function that 
881 @c is both called and compared, as *_XtInherit* is. This was handled by putting 
882 @c *_XtInherit* in the same file as a function that is always used, thereby 
883 @c guaranteeing that it would be loaded -- that is, in Initialize.c, where 
884 @c XtToolkitInitialize() and XtInitialize() reside. These routines would normally
885 @c be called.
886 @c 
887 @c      You are probably seeing this error because your program is not a normal
888 @c Xt-based program and does not call XtToolkitInitialize() anywhere. 
889 @c      1) it may be a program that uses Xt functions but never opens a 
890 @c connection to the X server.  [OSF/Motif's 1.1.0 UIL had this problem; it called
891 @c XtMalloc() and other Xt functions.] The solution is to add the call to your 
892 @c program; the function does not have to be executed, just linked in.
893 @c      2) alternatively, your program doesn't need any Xt functions and is
894 @c correct in not calling XtToolkitInitialize() -- it may be an Xlib or XView 
895 @c program. In this case, you can remove -lXt from your link command. 
896 @c 
897 @c      It should not be necessary to link the shared libraries statically,
898 @c although this will certainly solve the problem.
899
900 @c * Empty Makefiles::             If configure gives you sed errors.
901 @c * wchar_t::                     For wchar_t difficulties.