cvs commit: hints errors.txt

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Wed Oct 8 18:10:57 PDT 2003


tushar      03/10/08 19:10:57

  Added:       .        errors.txt
  Log:
  Added hints errors
  
  Revision  Changes    Path
  1.1                  hints/errors.txt
  
  Index: errors.txt
  ===================================================================
  AUTHOR:	Alex Kloss <alex at 22-music.com>
  
  DATE: 2003-10-07
  
  LICENSE: GNU Free Documentation License Version 1.2
  
  SYNOPSIS: What to do on errors
  
  DESCRIPTION:
  The LFS Book has a short, but nice chapter about errors. A longer essay about 
  how to spot where the error is, how to describe it (on IRC or the mailing 
  list), and possibly get around it is the goal of this hint.
  
  PREREQUISITES:
  Common sense, LFS, patience.
  
  HINT:
  Almost every LFS adept has seen lines like:
  
  - make[1]: Error
  - Segmentation Fault
  - ld returned signal 2: ...
  
  The first urge is to write to the mailing list or on IRC something like:
  
  I have an error in program <fill in whatever is appropriate>!
  
  Mostly further informations about the errors are missing, which is a nuisance
  for both the one who asks and the one who tries to answer, because of the
  annoying dialogue that is often following. I have to admid that the LFS mailing
  list and IRC never failed to solve my problems (and that in a rather cheerful
  way), but I reached a point at where I wanted to solve as much of my problems
  myself. So I had to learn a much, which was undoubtedly fun.
  
  WHAT KIND OF ERROR?
  
  You have to distinguish between the different kinds of errors. The more you 
  can tell about the error, the easier it is to solve.
  
  This should be a normal hint, but I guess it is easier to draw a chart:
  
  Question: When did it happen?   What happened?      Where did it happen?
  
                                                    , Compiling (gcc) ...
                                , ... not found ---<
            Compile-time Error <                    ` Linking (ld)
         ,'                     `.
  Error <                          Segfault
         `.                     ,'
            Run-time Error ----<          , full
                                ` Hangup <
                                          ` Prog 
          				  only
  
  That looks pretty simple, eh? But that's only the beginning. We will have a 
  look at each of these error types closely!
  
  1. Compile-time Errors
  
  When you are about to ./configure && make && make install your package, you
  sometimes get the error that something is missing or malformed or simply
  uncompileable.
  
  1.1 ... not found
  
  1.1.1 Compiling (gcc)
  
  There is a lot gcc may be unable to find. If there is something to include, it 
  may be the file that should be included, that is missing. The questions here 
  are: 1. what's missing? and 2. what to do against?
  
  1.1.1.1 Missing header file
  
  If only a header file is missing, you will experience an error message like:
  
  foo.c:3:31: /usr/include/bar.h: No such file or directory
  
  If there's a file missing, you may want to search your system for it:
  
  find / -name <filename> or
  locate <filename> (run updatedb, if locate demands it)
  
  If you don't find the file, the next question would be: where should this file
  come from? Is there a prerequisite you forgot? Are all tools available in the 
  required versions?
  
  In most cases the file will be in another directory than the developer thinks 
  it is. The easiest way around that would be a symlink, but that is not a clean
  way. So we search the sources for occurrences of the "missing" file first:
  
  grep -R "<missing file's path and name>" *.*
  
  Now edit every file that uses the wrong path in it's #include statements. The
  lazy user can utilize sed:
  
  for i in *.*; do 
   mv $i $i.bak
   sed s|'<"missing" file>'|'<found file'>|g $i.bak > $i
  done
  
  This should solve the problem; you can continue building the package.
  
  1.1.1.2 Missing declaration
  
  Another fine errormessage goes about a missing declaration:
  
  foo:124:4: bla undefined
  
  if "bla" is a function from generic libraries (like glibc), it will probably be
  documented with a manpage which holds informations about which header file(s)
  it needs to be included:
  
  man bla
  
  Look at /usr/share/man/man3 for documented function calls: The manpage will
  look something like that:
  
  --snip
  FUNC(3)				Linux Programmer's Manual		FUNC(3)
  
  NAME
  	func, ffunc, vfunc - Example function without any use
  
  SYNOPSIS
  	#include <stdfunc.h>
  	int func(char *format, ...);
  	int ffunc(FILE *stream, const char *format, ...);
  
  	#include <vstdfunc.h>
  	int vfunc(const char *format, va list ap);
  
  DESCRIPTION
  ...
  --snap
  
  In most of the cases the header file is not included where it's neccessary, so
  you just write it into the file where it is missing: "#include <stdfunc.h>".
  
  If the definition is nowhere any standard library, you will have to search the
  codebase of the program you are about to compile for the function it's missing:
  
  grep "<function name>" *.* | less
  
  Now search for something like "#define bla ( const char * ...". If you don't
  find anything, the function is likely to be included in other sources, so you
  better check the requirements of the package you are about to compile, in case
  something is missing.
  
  If the file where the definition is included is a header file (*.h), simply
  include it, otherwise copy and paste the definition into the file gcc is
  complaining about.
  
  1.1.2 Linking (ld)
  
  Linking mostly fails because of missing libraries. Make sure your
  /etc/ld.so.conf contains all directories with libraries in it. In case, another
  directory is needed, use LDFLAGS: "export LDFLAGS=-L/usr/X11R6/lib" to include
  XFree86's libraries for sure.
  
  1.2 Segmentation Fault
  
  This is most annoying. It means an application had an error that is so bad it
  rather drops core and stop immediately.
  
  1.2.1 Segfault during compilation
  
  Segmentation faults during compilation are very seldom. You only get SIG11 if
  the memory is full while building a package and will happen only on systems
  with few memory. You can add a loop device to swap to expand your memory; this
  will make compilation much slower, but at least it will work on such devices
  that contains too few memory:
  
  dd if=/dev/zero of=/tmp/swapspace bs=1M count=128
  losetup /dev/loop0 /tmp/swapspace
  mkswap /dev/loop0
  swapon /dev/loop0
  
  will set up 128MB of swap space (or virtual memory). If it still fails,
  increase the amount of disk space used (count=256; count=512; count=XXX).
  
  1.2.2 Segfault during execution
  
  If a program segfaults, there isn't much you can easily do to hunt the error
  down if you don't have some programming skills. Contact the developer and give
  him a detailed view of your system; maybe in /var/log is something about the
  error?
  
  1.3 Hangup
  
  Hangups are the most annoying errors there are. Fortunately, they are as seldom
  as annoying with Linux (unless you use bleeding edge sources only).
  
  1.3.1 Full Hangup
  
  You recognize a full hangup by pressing the [CAPS LOCK] key. If the led is
  flashing, the keyboard is still hooked to the console, so that's no full
  hangup. Try pressing different keys then. If nothing else works, use a hard 
  reboot (that is always the last means of getting back to work). If the
  keyboard is still available, but the screen is blank, try to reboot with
  [ALT][CTRL][DEL]. If even that doesn't work, you may be lucky to have the sysrq
  key feature compiled into your kernel. For further informations, read
  [/usr/src/linux/Documentation/sysrq.txt].
  
  1.3.2 Program-only Hangup
  
  If the program hangs up leaving the rest of the system intact, you can use the
  kill command to get rid of it. 
  
  Hope this was helpful!
  Alex
  
  CHANGELOG:
    [2002-01-04]
      * Started to write this hint.
  
    [2003-10-07]
      * Initial Version.
  
  
  



More information about the hints mailing list