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

时间:2012-09-04 11:51:26

标签: linux glib pkg-config

我尝试安装udev。而且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 

好的,缺少pkg-config和glib-2.0。

起初我尝试安装pkg-config。我收到了这条消息:

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

好的,我解释说,缺少滑稽。

下一步安装Glib。

我收到了这条消息:

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.

但我现在很困惑。 他们需要彼此吗? 我的错是什么?

4 个答案:

答案 0 :(得分:28)

正如您已经观察到的那样,pkg-config和glib之间确实存在循环依赖关系。为了打破它,pkg-config的source code包含一个glib版本,足以编译它。这应该打破依赖周期。

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

答案 1 :(得分:8)

它已包含在glib错误消息中:

  

或者,您可以设置环境变量LIBFFI_CFLAGS   和LIBFFI_LIBS,以避免需要调用pkg-config。   有关更多详细信息,请参见pkg-config手册页。

Glib构建脚本使用pkg-config查找libffi。但您也可以通过设置环境变量手动提供信息。然后不需要调用pkg-config。 Glib本身根本不需要pkg-config。

pkg-config人员提供了另一个问题的解决方案。同样,在错误消息的末尾:

  

请将GLIB_CFLAGS和GLIB_LIBS设置为正确的值或   传递--with-internal-glib来配置

在这种情况下,pkg-config本身包含了构建所需的所有内容,而系统上没有Glib。

答案 2 :(得分: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.

答案 3 :(得分:0)

libudev现在是systemd的一部分,它不依赖于glib。

大多数Linux发行版为pkg-config,libudev和glib提供二进制文件。它们可能已经安装,但如果没有,您可以使用包管理器来获取它们。

如果你确实需要自己编译这些东西,可以考虑使用pkgconf,这是一个不使用glib的pkg-config的轻量级实现。