29

I try to install udev. And udev gives me an error during the ./configure

--exists: command not found configure: error:
pkg-config and "glib-2.0 >= 2.16" not found, please set GLIB_CFLAGS and GLIB_LIBS
to the correct values or pass --with-internal-glib to configure 

Ok, pkg-config and glib-2.0 is missing.

At first I tried to install pkg-config. I got this message:

checking whether to list both direct and indirect dependencies... no
checking for Win32... no
checking if internal glib should be used... no
checking for pkg-config... no
./configure: line 13557: --exists: command not found
configure: error: pkg-config and "glib-2.0 >= 2.16" not found,
please set GLIB_CFLAGS and GLIB_LIBS to the correct values or 
pass --with-internal-glib to configure

Ok I interpret, that glib is missing.

Next step installing Glib.

And I got this message:

configure: error: in `/root/glib-2.33.3':
configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

But I'm puzzled now. Do they need each other? What is my mistake?

4 Answers 4

35

As you have already observed, there is indeed a circular dependency between pkg-config and glib. To break it, pkg-config's source code includes a version of glib, which is enough to compile it. This should break the dependency cycle.

Try configuring pkg-config with --with-internal-glib.

10
  • Thanks for the answer. That worked, but the error messages of glib and udev still remained
    – Peter
    Sep 4, 2012 at 13:11
  • 3
    @Peter have you tried compiling udev with ./configure --with-internal-glib? Sep 4, 2012 at 14:40
  • @Peter absolutely try that. I can't stress enough how important it is to read error messages carefully and understand what they mean!
    – ptomato
    Sep 4, 2012 at 17:23
  • Nice try: ./configure --with-internal-glib configure: WARNING: unrecognized options: --with-internal-glib
    – Peter
    Sep 6, 2012 at 6:36
  • pkg-config is installed now. But the next think appeared during config udev. I read the error message carefully. And I think I understood what the error is nearly, but I don't know how to fix it. Here is the error message: error: Package requirements (usbutils >= 0.82) were not met: No package 'usbutils' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables USBUTILS_CFLAGS and USBUTILS_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
    – Peter
    Sep 6, 2012 at 7:19
8

It is already contained on the glib error message:

Alternatively, you may set the environment variables LIBFFI_CFLAGS and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.

The Glib build script uses pkg-config to find libffi. But you can provide the information also manually, by setting environment variables. Then the call to pkg-config is not necessary. Glib itself does not need pkg-config at all.

Another solution to the problem is provided by the pkg-config people. Again, at the end of the error message:

please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure

In this scenario, pkg-config itself is packaged with everything necessary to build without having Glib on your system already.

2
  • 1
    If you don't know how to do the first solution, doing the second solution is a no-brainer.
    – ypnos
    Sep 4, 2012 at 13:01
  • Thanks for the answer. That worked with the second way, but the error messages of glib and udev still remained
    – Peter
    Sep 4, 2012 at 13:11
1
export GLIB_CFLAGS="$(pkg-config --cflags glib-2.0)" 
export GLIB_LIBS="$(pkg-config --libs glib-2.0)"
printf '# In the case of a RHEL6.5\n\tGLIB_CFLAGS=%s\n\tGLIB_LIBS=%s\n' "$GLIB_CFLAGS" "$GLIB_LIBS"
# In the case of a RHEL6.5
        GLIB_CFLAGS=-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
        GLIB_LIBS=-lglib-2.0

# _now_ it is a no-brainer.
1
  • 5
    Could you please add some explanation
    – Narendra
    May 6, 2014 at 10:28
0

libudev is now part of systemd and it doesn't depend on glib.

Most Linux distributions provide binaries for pkg-config, libudev, and glib. They are probably installed already, but if not, you can use the package manager to get them.

If you do need to compile this stuff yourself, consider using pkgconf, a light-weight implementation of the pkg-config that does not use glib.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.