3
  1. Does deleting a package in Ubuntu delete the associated header files too?
  2. Is there a difference between installing packages manually and using the apt command?
  3. How to find the right package name required for particular header-file?
  4. Why does the code mentioned below runs when the header file is not present?

Details:

I installed LIBABW using : sudo apt-get install libabw-dev and also manually using the tar.gz package earlier.

I wrote a simple C++ code to extract data from Abiword files using libabw. The header files included in the code are

#include <stdio.h>
#include <string>
#include <cstring>

#include <librevenge-generators/librevenge-generators.h>
#include <librevenge-stream/librevenge-stream.h>
#include <libabw/libabw.h>

This is the command I run to compile the code:

g++ libabw.cc -I/usr/local/include/librevenge-0.0 -I/usr/local/include/libabw-0.1 -I/usr/local/include/librevenge-0.0 -I/usr/include/libxml2 -L/usr/local/lib -lrevenge-generators-0.0 -labw-0.1 -lrevenge-0.0 -lrevenge-stream-0.0

Now I deleted the libabw-dev package, manually from the extracted folder and also using

sudo apt-get purge --auto-remove libabw-dev

The code I wrote still compiles and still extracts data from Abiword documents.

On running apt-file -x search '/libabw/libabw.h$', I get the output libabw-dev: /usr/include/libabw-0.1/libabw/libabw.h. But the directory /usr/include/libabw-0.1 doesn't exists.

  • 1
    *Running* a program does not require any header files to be present. *Compiling* a program may require the headers. – Jesper Juhl Jul 31 '20 at 17:00

1 Answers1

3

Does deleting a package in Ubuntu delete the associated header files too?

Deinstalling a package removes all files that belong to this package. If it's a -dev package, there are oftentimes header files as part of the package. On the other hand, if you have the libfoo package installed as well as libfoo-dev, and you deinstall libfoo only, the libfoo-dev package might remain on your system, and with it, the header files.

Is there a difference between installing packages manually and using the apt command?

Absolutely. Manually installing files just means you put some files somewhere on your system. If you install a package, your package manager keeps track of what is installed where. This is necessary to a proper clean-up etc. Also, packages are configure such that libraries and headers end up under paths that are usually found by linker and compiler, respectively. You can do that manually, too, but it's error prone - and more importantly, messing around with standard installation paths of your package managers (e.g. manually putting some files in a directory which apt writes to itself) might compromise parts of your system.

How to find the right package name required for particular header-file?

I don't know of any package that splits individual header fiels across packages. If you're interested in the headers of foo, check whether apt-cache search foo yields a -dev package. That should be sufficient.

Why does the code mentioned below runs when the header file is not present?

The compiler will complain immediately if it doesn't find an #included file somewhere in its search paths. Hence, the file is present. If you have deinstalled the package that delivered a particular header, then the remaining manual installation must still be around. As you said that you installed the headers both manually and with apt, I suspect the manual installation is still visible to the compiler.

lubgr
  • 37,368
  • 3
  • 66
  • 117