Linux glib 需要 pkg-config 而 pkg-config 需要 glib?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12262925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux glib needs pkg-config and pkg-config needs glib?
提问by Peter
I try to install udev. And udev gives me an error during the ./configure
我尝试安装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
Ok, pkg-config and glib-2.0 is missing.
好的,缺少 pkg-config 和 glib-2.0。
At first I tried to install pkg-config. I got this message:
起初我尝试安装 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
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?
但我现在很困惑。他们需要彼此吗?我的错误是什么?
采纳答案by user1202136
As you have already observed, there is indeed a circular dependency between pkg-config and glib. To break it, pkg-config's source codeincludes a version of glib, which is enough to compile it. This should break the dependency cycle.
正如您已经观察到的,pkg-config 和 glib 之间确实存在循环依赖。要破解它,pkg-config 的源代码包含一个 glib 版本,足以编译它。这应该打破依赖循环。
Try configuring pkg-config with --with-internal-glib
.
尝试使用--with-internal-glib
.
回答by ypnos
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. See the pkg-config man page for more details.
或者,您可以设置环境变量 LIBFFI_CFLAGS 和 LIBFFI_LIBS 以避免调用 pkg-config。有关更多详细信息,请参阅 pkg-config 手册页。
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.
Glib 构建脚本使用 pkg-config 来查找 libffi。但是您也可以通过设置环境变量手动提供信息。那么就不需要调用 pkg-config 了。Glib 本身根本不需要 pkg-config。
Another solution to the problem is provided by the pkg-config people. Again, at the end of the error message:
该问题的另一个解决方案是由 pkg-config 人员提供的。同样,在错误消息的末尾:
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。
回答by fned
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.
回答by David Grayson
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. They are probably installed already, but if not, you can use the package manager to get them.
大多数 Linux 发行版都提供了 pkg-config、libudev 和 glib 的二进制文件。它们可能已经安装,但如果没有,您可以使用包管理器来获取它们。
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 的轻量级实现。