9.6 Troubleshooting Compiles and Installations


9.6 Troubleshooting Compiles and Installations

If you understand the difference between compiler errors, compiler warnings, linker errors, and shared library problems as described in Chapter 8, then you should not have too much trouble fixing many of the glitches that arise when building software. This section covers some other common problems.

Before getting into specifics, you should learn to read make output. You first need to know the difference between an error and an ignored error. The following is a real error that you need to investigate:

 make: *** [  target  ] Error 1 

However, some Makefiles suspect that an error condition may occur but know that these errors are harmless. You can usually disregard any messages like this:

 make: *** [  target  ] Error 1 (ignored) 

Furthermore, GNU make often calls itself many times in large packages, with each instance of make in the error message marked with [ N ] , where N is a number. You can often find the error quickly by looking at the make error that comes directly after the compiler error message. Here is an example:

  [compiler error message involving  file  .c]  make[3]: *** [file.o] Error 1 make[3]: Leaving directory '/home/src/package-5.0/src' make[2]: *** [all] Error 2 make[2]: Leaving directory '/home/src/package-5.0/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/src/package-5.0/' make: *** [all] Error 2 

The first three lines practically give it away ” the trouble centers around file.c located in /home/src/package-5.0/src . Unfortunately, there is so much extra output that it can be difficult to spot the important details. Learning how to filter out the subsequent make errors goes a long way toward digging out the real cause.

9.6.1 Specific Errors

Problem: Compiler error message:

 src.c:22: conflicting types for '  item'  /usr/include/  file  .h:47: previous declaration of '  item  ' 

Explanation and Fix: The programmer made an erroneous redeclaration of item on line 22 of src.c . You can usually fix this by removing the offending line (with a comment, an #ifdef , or whatever works).

Problem: Compiler error message:

 src.c:37: `time_t' undeclared (first use this function) ... src.c:37: parse error before `...' 

Explanation and Fix: The programmer forgot a critical header file. The manual pages are the best way to find the missing header file. First, look at the offending line (in this case, it's line 37 in src.c ). It's probably a variable declaration like the following:

 time_t v1; 

Search forward for v1 in the program for its use around a function call. For example:

 v1 = time(NULL); 

Now run man 2 time or man 3 time to look for system and library calls named time() . In this case, the section 2 manual page has what you need:

 SYNOPSIS       #include <time.h>       time_t time(time_t *t); 

This means that time() requires time.h . Place #include <time.h> at the beginning of src.c and try again.

Problem: Compiler (preprocessor) error message:

 src.c:4:  pkg  .h: No such file or directory (long list of errors follows) 

Explanation and Fix: The compiler ran the C preprocessor on src.c , but could not find the pkg .h include file. The source code likely depends on a library that you need to install, or you may just need to provide the compiler with the nonstandard include path (see Section 9.2.2 if the package uses GNU autoconf). In most cases, you just need to add a -I include path option to the C preprocessor flags ( CPPFLAGS ). Keep in mind that you may also need a -L linker flag to go along with the include files.

If you are using a graphics application and see Xm and Mrm in the error message, you are missing the Motif library. LessTif is a free replacement for Motif; if it is not on your system, you can get it at http://www.lesstif.org/.

If it doesn't look as though you're missing a library, there's also an outside chance that you are attempting a compile for an operating system that this source code does not support. Check the Makefile and README files for details about platforms.

Problem: make error message:

 make:  prog:  Command not found 

Explanation and Fix: To build the package, you need prog on your system. If prog is something like cc , gcc , or ld , you don't have the development utilities installed on your system. On the other hand, if you think prog is already installed on your system, try altering the Makefile to specify the full pathname of prog .

In rare cases, make builds prog and then uses prog immediately, assuming that the current directory (.) is in your command path. If your $PATH does not include the current directory, you can edit the Makefile and change prog to ./ prog . Alternatively, you could append . to your path temporarily.

Problem: Undefined symbols that start with SM_ and ICE_ .

Explanation and Fix: Some packages that link against X Window System libraries also need the -lSM and -lICE linker flags.




How Linux Works
How Linux Works: What Every Superuser Should Know
ISBN: 1593270356
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Brian Ward

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net