本人在linux fedora8 下编译wxWidgets,在编译过程中碰到如下的错误:

*** Could not run GTK+ 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 GTK+ is incorrectly installed.
configure: error:
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that
gtk+-2.0.pc
is
installed
. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.

我上网查找了很多类似的问题,很多朋友都说gtk相关的软件没有安装,但是不仅仅是这些问题,下面简单的说说如何解决这个问题。

1.pkg-config是否安装?

pkg-config是干什么用的我就不介绍了,大家可以问google或者baidu。可以通过pkg-config --version查看版本,也可以检查是否安装,本人电脑上的命令的路径为:/usr/bin。

若没有安装通过如下命令安装:

yum list pkgconfig(列出可用的安装包)

[root@fedora8 contrib]# yum list pkgconfig
已经安装的包
pkgconfig.i386                      1:0.22-3.fc8                       installed
pkgconfig.i386                      1:0.22-4.fc8                       installed

yum install pkgconfig(安装pkgconfig)

2.gtk是否安装?

$pkg-config --modversion gtk+    (查看1.2.x版本)
$pkg-config --modversion gtk+-2.0  (查看 2.x 版本)

$pkg-config --list-all |grep gtk (查看是否安装了gtk)

[root@fedora8 contrib]# yum list *gtk+*
已经安装的包
gtk+.i386                             1:1.2.10-59.fc8                  installed
gtk+-devel.i386                       1:1.2.10-59.fc8                  installed
gtk+extra.i386                        2.1.1-7.fc8                      installed
gtk+extra-devel.i386                  2.1.1-7.fc8                      installed

上面情况说明已经安装了gtk,若是没有安装,逐个的使用下面的命令进行安装

yum install gtk+.i386

3.进行配置

上面错误提示 pkg-config  gtk+-2.0.pc 的路径有问题,提示找不到gtk+-2.0.pc文件,需要把包含该文件的目录放到PKG_CONFIG_PATH里,搜索了一下,该文件在/usr/lib/pkgconfig下,于是更改环境变量成:

[root@fedora8 contrib]# export PKG_CONFIG=/usr/bin/pkg-config
[root@fedora8 contrib]# export PKG_CONFIG_PATH=/usr/share/pkgconfig:/usr/lib/pkgconfig
记住:两个路径之间用 ':' 隔开,不是 ',', 或者 ';'。不让会出大问题。

可以用echo $PKG_CONFIG来查看环境变量是否设置成功。希望我的经验对你有用!


GitHub 加速计划 / li / linux-dash
11
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐