When compiling a source package, I got an error from make
that looked like:
In file included from foo.c:28:0:
bar.h:23:18: fatal error: bar.h: No such file or directory
#include <bar.h>
^
compilation terminated.
make[x]: *** [baz] Error 1
make[x]: Leaving directory
How do I handle this?
Best Answer
This typically indicates that you haven't installed some dependency of the program you are trying to compile. Depending on the header file in question and the program you are trying to compile, you have a couple of options:
Target software exists in the Ubuntu repositories
Sometimes you want to compile from source a package already provided by Ubuntu (to get a different version, perhaps, or to patch it). If the software hasn't changed too much, you can use
apt
to get the dependencies:This should install all the packages needed to build the Ubuntu package of that software (which may have fewer or more packages than what your source package actually needs).
If you only need to make some minor change in the source, or apply a patch, you might even be able to save a significant bit of effort by letting
apt
anddpkg
do the legwork:This will download the source files of the package, including everything needed to make a package of it. The files will be in a directory named
<package-name>-<some-version>
. Enter it, make all the changes you want, and then do:This creates unsigned binary package(s) in the parent directory (
cd ..
). You can then usedpkg
to install these packages:Examples:
Target software is not present in the Ubuntu repositories
You can still try your luck with the specific header file missing. Use either the Ubuntu Packages index (the option to search the contents of packages) or
apt-file
to search for the file. Sometimes multiple packages may provide similarly named files, in which case, prefer:/usr/include
.uname -m
to know what your architecture is).README
andINSTALL
files in the source (if present).-dev
, which typically include headers needed for compiling.See: How do I find the package that provides a file?