【问题标题】:Linux glib needs pkg-config and pkg-config needs glib?Linux glib 需要 pkg-config 和 pkg-config 需要 glib?
【发布时间】:2012-08-29 01:55:25
【问题描述】:

我尝试安装 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 不见了。

下一步安装 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.

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

【问题讨论】:

    标签: linux glib pkg-config


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的回答。这行得通,但 glib 和 udev 的错误消息仍然存在
    • @Peter 你试过用./configure --with-internal-glib编译udev吗?
    • @Peter 绝对可以试试。仔细阅读错误消息并理解它们的含义是多么重要!
    • 不错的尝试:./configure --with-internal-glib configure: WARNING: unrecognized options: --with-internal-glib
    • pkg-config 现已安装。但是下一个想法出现在配置 udev 期间。我仔细阅读了错误信息。而且我想我几乎了解错误的含义,但我不知道如何解决它。这是错误消息: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.
    【解决方案2】:

    它已经包含在 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。

    【讨论】:

    • 如果你不知道如何做第一个解决方案,那么做第二个解决方案是很容易的。
    • 感谢您的回答。第二种方法有效,但 glib 和 udev 的错误消息仍然存在
    【解决方案3】:
    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.
    

    【讨论】:

    • 能否请您添加一些解释
    【解决方案4】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      相关资源
      最近更新 更多