gpt4 book ai didi

linux - 从源代码编译 atk

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:53:07 26 4
gpt4 key购买 nike

我尝试从源代码编译 atk 2.7.91。由于我在较旧的 ubuntu 系统上工作,因此没有所需 glib 版本的最新软件包。所以我刚刚下载了 glib 2.35.8 并成功地完成了 ./configuremake (我不想在系统范围内安装它所以我没有这样做进行安装)。

假设这个 glib 在 /foobar/glib-2.35.8 中。现在我 cd/foobar/atk-2.7.91 并导出 PKG_CONFIG_PATH: export PKG_CONFIG_PATH=/foobar/glib-2.35 .8:$PKG_CONFIG_PATH.

然后

pkg-config --modversion glib-2.0

告诉我:

2.35.8

但是当我执行 ./configure 时,我收到错误消息:

checking for GLIB - version >= 2.31.2... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error:
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** but not in the same location as pkg-config add the location of the file
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.

cat config.log |grep glib 给出:

configure:12143: checking for GLIB - version >= 2.31.2
configure:12258: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES conftest.c -L/usr/local/lib -lgobject-2.0 -lglib-2.0 >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
| fclose (fopen ("conf.glibtest", "w"));
| if ((glib_major_version != 2) ||
| (glib_minor_version != 35) ||
| (glib_micro_version != 8))
| printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
| glib_major_version, glib_minor_version, glib_micro_version);
| printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
| else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
| (glib_minor_version != GLIB_MINOR_VERSION) ||
| (glib_micro_version != GLIB_MICRO_VERSION))
| printf("*** GLIB header files (version %d.%d.%d) do not match\n",
| GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
| glib_major_version, glib_minor_version, glib_micro_version);
| if ((glib_major_version > major) ||
| ((glib_major_version == major) && (glib_minor_version > minor)) ||
| ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
| printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n",
| glib_major_version, glib_minor_version, glib_micro_version);
| printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n",
| printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
| printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
configure:12304: gcc -o conftest -g -O2 -Wall -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES conftest.c -L/usr/local/lib -lgobject-2.0 -lglib-2.0 >&5
conftest.c:25:18: fatal error: glib.h: No such file or directory
| #include <glib.h>
| return ((glib_major_version) || (glib_minor_version) || (glib_micro_version));
*** GLIB 2.31.2 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.
ac_cv_env_PKG_CONFIG_PATH_value=/foobar/glib-2.35.8/:
GLIB_CFLAGS=''
GLIB_COMPILE_RESOURCES=''
GLIB_GENMARSHAL=''
GLIB_LIBS=''
GLIB_MKENUMS=''
GLIB_PACKAGES='gobject-2.0'
GLIB_REQUIRED_VERSION='2.31.2'
PKG_CONFIG_PATH='/foobar/glib-2.35.8/:'

知道这里出了什么问题以及如何解决吗?

最佳答案

简短回答

手册(几乎)始终是您的 friend 。尝试查看 man pkg-config,您会发现它是 pkg-config 执行其工作所需的 .pc 文件。 glib-2.0.pc 在你的情况下。不幸的是,这并不像指向它的存储位置那么简单,但请将其留作最后的长答案,并先看一下手册页。

pkg-config retrieves information about packages from special metadata files. These files are named after the package, and has a .pc extension. On most systems, pkg-config looks in and for these files. It will additionally look in the colon-separated (on Windows, semicolon-separated) list of directories specified by the PKG_CONFIG_PATH environment variable.

The package name specified on the pkg-config command line is defined to be the name of the metadata file, minus the .pc extension. If a library can install multiple versions simultaneously, it must give each version its own name (for example, GTK 1.2 might have the package name "gtk+" while GTK 2.0 has "gtk+-2.0").

希望你觉得有趣

On most systems, pkg-config looks in and for these files

行。结果可能在您的系统上有所不同,但在我的系统上它实际上以这种方式显示,这很可能是一个错误。

尽管如此,您可以通过运行找到在标准目录中编译的pkg-config --variable pc_path pkg-config 例如打印

/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/i486-linux-gnu:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib/pkgconfig/i486-linux-gnu:/usr/share/pkgconfig

在我的系统上。

长答案

回到您最初的问题,查看示例 .pc 文件可能最好地解释为什么您的第一次努力是徒劳的。作为示例,我系统上的 glib-2.0.pc 文件的内容:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 2.24.2
Libs: -L${libdir} -lglib-2.0
Libs.private:
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

正如您希望看到的那样,整个路径都是硬连线的。不要被 ${libdir} ... 之类的东西搞糊涂了。仔细观察,您会发现它们都是从第一行的 prefix=/usr 构造的。

尝试将 PKG_CONFIG_PATH 指向 glib 的构建目录的原因是行不通的,因为 .pc 中指定的路径是安装目录,而不是构建目录的位置。

这就是为什么您的 pkg-config --modversion 测试运行得很好:确实找到了 .pc 文件并包含了给定的信息,但是编译失败了: .pc 文件和第一种情况一样找到了,但是 .pc 文件中给出的路径完全错误。

没有人可以禁止您将 .pc 中给出的目录更改为您喜欢的任何路径,因此实际上您可以通过手动修复.pc 文件中给出的路径。至少如果库本身不包含任何硬连线路径,但这只会在运行时出现问题,而不是在链接时出现问题。

甚至要解决最后一个难题 - .pc 文件他妈的怎么知道它要安装到哪里才能给出正确的前缀?只要看看你的源目录。在 glib-2.0.pc 文件旁边,您会发现一个名为 glib-2.0.pc.in 的文件,其内容如下所示:

prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: @VERSION@
Requires.private: @PCRE_REQUIRES@
Libs: -L${libdir} -lglib-2.0 @INTLLIBS@
Libs.private: @G_THREAD_LIBS@ @G_LIBS_EXTRA@ @PCRE_LIBS@ @INTLLIBS@ @ICONV_LIBS@
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include @GLIB_EXTRA_CFLAGS@

当您运行 configure 时,整个 @....@ 占位符在配置时填写。即 @prefix@ 填充了在命令行上作为 --prefix= 给出的参数,而其他像 @NTLLIBS@ 填充了配置脚本检测到的参数。

关于linux - 从源代码编译 atk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15005935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com