简体   繁体   English

Linux glib需要pkg-config和pkg-config需要glib吗?

[英]Linux glib needs pkg-config and pkg-config needs glib?

I try to install udev. 我尝试安装udev。 And udev gives me an error during the ./configure 并且udev在./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. 好的,缺少pkg-config和glib-2.0。

At first I tried to install pkg-config. 起初我尝试安装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. 下一步安装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? 我的错是什么?

As you have already observed, there is indeed a circular dependency between pkg-config and glib. 正如您已经观察到的那样,pkg-config和glib之间确实存在循环依赖关系。 To break it, pkg-config's source code includes a version of glib, which is enough to compile it. 为了打破它,pkg-config的源代码包含一个glib版本,足以编译它。 This should break the dependency cycle. 这应该打破依赖循环。

Try configuring pkg-config with --with-internal-glib . 尝试使用--with-internal-glib配置pkg-config。

It is already contained on the glib error message: 它已包含在glib错误消息中:

Alternatively, you may set the environment variables LIBFFI_CFLAGS and LIBFFI_LIBS to avoid the need to call pkg-config. 或者,您可以设置环境变量LIBFFI_CFLAGS和LIBFFI_LIBS以避免需要调用pkg-config。 See the pkg-config man page for more details. 有关更多详细信息,请参见pkg-config手册页。

The Glib build script uses pkg-config to find libffi. Glib构建脚本使用pkg-config来查找libffi。 But you can provide the information also manually, by setting environment variables. 但您也可以通过设置环境变量手动提供信息。 Then the call to pkg-config is not necessary. 然后不需要调用pkg-config。 Glib itself does not need pkg-config at all. Glib本身根本不需要pkg-config。

Another solution to the problem is provided by the pkg-config people. pkg-config人员提供了另一个问题的解决方案。 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 请将GLIB_CFLAGS和GLIB_LIBS设置为正确的值或传递--with-internal-glib进行配置

In this scenario, pkg-config itself is packaged with everything necessary to build without having Glib on your system already. 在这种情况下,pkg-config本身包含了构建所需的所有内容,而系统上没有Glib。

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.

libudev is now part of systemd and it doesn't depend on glib. libudev现在是systemd的一部分,它不依赖于glib。

Most Linux distributions provide binaries for pkg-config, libudev, and glib. 大多数Linux发行版都为pkg-config,libudev和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. 如果你确实需要自己编译这些东西,可以考虑使用pkgconf ,这是一个不使用glib的pkg-config的轻量级实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM