I am developing an application in which I require to use PolicyKit and it appears PolicyKit uses Glib libraries. What happens is that I installed PolicyKit, but the location of the headers are on /usr/include/polkit-1/ and /usr/include/glib-2.0.

and the headers have on their inside locations like /usr/include/, /usr/include/polkit, /usr/include/gobject.

I can't compile because the compiler doesn't find the headers in the location the headers say they are supposed to be. I tried modifying each header individually, but its taking too long and I don't know when I'll be done.

The problem here is that when they are installed, they are installed in /usr/include/polkit-1 and /usr/include/glib-2.0 when they are supposed to be installed in /usr/include alone. In other words, the folder polkit-1 and glib-2.0 shouldn't be there. Anyone know of anyway to fix this quickly by putting the files and folders in their respective locations?

3 Answers 3


I don't know the details, but some packages and libraries will install their files that way and also install files with their paths so that you can use pkg-config to find the correct paths.

I don't have polkit, but here, for glib-2.0, I can ask pkg-config to give me the "cflags" to use and compile with the library glib-2.0 ("cflags" being flags to use with the C compiler, to specify include paths and libraries to add when linking):

$ pkg-config --cflags --libs glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include  -lglib-2.0

I'd guess, for polkit-1, you'd do $ pkg-config --cflags --libs glib-2.0 polkit-1

To compile with these parameters, either store them in variables in a makefile, copy their result or you can even just call pkg-config directly in the shell — as in the following example from the manpage:

cc program.c $(pkg-config --cflags --libs gnomeui)

(Actually, that example is a Makefile rule, but you can do it in the shell too.)

For some details, see the manpage, and check which .pc files are available under /usr/lib/pkgconfig, /usr/share/pkgconfig and their /usr/local counterparts.

AFAIK, this is the portable way to compile with external libraries.


I agree with Giles's comment and think that the pkg_command from njsg is great.

Another common strategy to enable the link editor, ld, locate library files is to add their directories to the environment variable LD_LIBRARY_PATH from the ld man page

from man ld

     The linker uses the following search paths to locate required
       shared libraries:

       1.  Any directories specified by -rpath-link options.

       2.  Any directories specified by -rpath options.  The difference
           between -rpath and -rpath-link is that directories specified by
           -rpath options are included in the executable and used at
           runtime, whereas the -rpath-link option is only effective at
           link time. Searching -rpath in this way is only supported by
           native linkers and cross linkers which have been configured
           with the --with-sysroot option.

       3.  On an ELF system, for native linkers, if the -rpath and
           -rpath-link options were not used, search the contents of the
           environment variable "LD_RUN_PATH".

       4.  On SunOS, if the -rpath option was not used, search any
           directories specified using -L options.

       5.  For a native linker, the search the contents of the environment
           variable "LD_LIBRARY_PATH".

Read the man page for further options.

Don't re-arrange packages.


Thanks. I fixed it by doing this:

sudo cp -r /usr/include/polkit-1/polkit /usr/include/polkit
sudo cp -r /usr/include/polkit-1/polkitagent /usr/include/polkitagent
sudo cp -r /usr/include/polkit-1/polkitbackend /usr/include/polkitbackend
sudo cp -r /usr/include/glib-2.0/gio /usr/include/gio
sudo cp -r /usr/include/glib-2.0/glib /usr/include/glib
sudo cp -r /usr/include/glib-2.0/gobject /usr/include/gobject
sudo cp -r /usr/include/glib-2.0/glib-object.h /usr/include/glib-object.h
sudo cp -r /usr/include/glib-2.0/glib-unix.h /usr/include/glib-unix.h
sudo cp -r /usr/include/glib-2.0/glib.h /usr/include/glib.h
sudo cp -r /usr/include/glib-2.0/gmodule.h /usr/include/gmodule.h

If anyone have the same problem and use this, one must not delete the glib-2.0 folder because its still going to be used.

Anyway now I'm missing glibconfig.h and its nowhere in the system. I don't know what to install to get it.

  • 2
    I strongly recommend not to do this. Don't change files under /usr (except under /usr/local), leave it for your distribution's package manager. If you're going to change stuff under /usr, which should be a last resort, at least use symbolic links: cd /usr/include && sudo ln -s polkit-1/* glib-2.0/* .. But the recommended option is to pass the proper -I directives when compiling. Or rather, to invoke pkg-config, which will take care of that. May 16, 2012 at 23:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .