Linux glib needs pkg-config and pkg-config needs glib?
Asked Answered
E

4

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?

Extravaganza answered 4/9, 2012 at 11:51 Comment(0)
C
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.

Claudeclaudel answered 4/9, 2012 at 12:29 Comment(10)
Thanks for the answer. That worked, but the error messages of glib and udev still remainedExtravaganza
@Extravaganza have you tried compiling udev with ./configure --with-internal-glib?Claudeclaudel
@Extravaganza absolutely try that. I can't stress enough how important it is to read error messages carefully and understand what they mean!Ringdove
Nice try: ./configure --with-internal-glib configure: WARNING: unrecognized options: --with-internal-glibExtravaganza
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.Extravaganza
I don't have any USB on my board so I don't want to install that usbutils. What is the value I should set the environment variables? to install udev, finally.Extravaganza
@Extravaganza You need to provide udev with a usb.ids file, otherwise it won't compile. Check the --with-usb-ids-path=DIR configure option.Claudeclaudel
@ user12 : Thanks for the Answer. Should I replace DIR with a real path? If I don't do that I get this message: error: pci.ids not found, try --with-pci-ids-path= Where do I get the path of .ids files? Thanks a lot for the support.Extravaganza
if I try to feed the ./configure with DIR dummies like that ./configure --with-pci-ids-path=DIR --with-usb-ids-path=DIR I got another error error: libacl not found Extravaganza
udev is a pretty central daemon with lots of dependencies. On Ubuntu it looks like this: libacl1 (>= 2.2.51-5), libc6 (>= 2.10), libglib2.0-0 (>= 2.16.0), libselinux1 (>= 1.32), upstart-job, libudev0 (>= 175), module-init-tools (>= 3.2.1-0ubuntu3), initramfs-tools (>= 0.92bubuntu63), procps, adduser, util-linux (>> 2.15~rc2), upstart (>= 1.4-0ubuntu6)Claudeclaudel
M
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.

Marathi answered 4/9, 2012 at 12:27 Comment(2)
If you don't know how to do the first solution, doing the second solution is a no-brainer.Marathi
Thanks for the answer. That worked with the second way, but the error messages of glib and udev still remainedExtravaganza
U
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.
University answered 6/5, 2014 at 9:38 Comment(1)
Could you please add some explanationHarebell
H
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.

Histrionism answered 2/8, 2017 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.