哪位大虾能帮我分析下这个脚本

sh/bash/dash/ksh/zsh等Shell脚本
回复
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

哪位大虾能帮我分析下这个脚本

#1

帖子 zwjiong » 2008-11-23 15:10

我在安装atk的时候出错,就是cofigure时就出错了
提示是这样的:
checking for GLIB - version >= 2.0.0...
*** 'pkg-config --modversion glib-2.0' returned 2.18.0, but GLIB (2.18.2)
*** was found! If pkg-config was correct, then it is best
*** to remove the old version of GLib. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
*** /etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH
*** to point to the correct configuration files

。。。。
首先我用的是UBUNTU8.10的,后来发现他内部是装了glib的2.18.2的,但是我又装了一个2.18.0在usr/local/lib下面,也可以从 'pkg-config --modversion glib-2.0' returned 2.18.0这里看出来,说明.pc文件也找到了~~~

然后去看他的configure文件,定为到出错的那部分
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
这应该就是读glib版本号,我的理解,因为pkg_config --modversiong是读版本的命令
后面内嵌C代码的语句:
if ((glib_major_version != $glib_config_major_version) ||
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
应该说是判断到了版本出错了,所以执行后面的printf语句。我对shell语言不是很懂,C语言还算有点了解的,菜鸟一个,我不知道glib_micro_version和$glib_micro_version这2个变量到底有什么区别~~~这里很明显是这2个变量不一致才出错的
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 哪位大虾能帮我分析下这个脚本

#2

帖子 xhy » 2008-11-23 15:28

包管理器认为glib2版本是2.18.0,而实际上找到的是2.18.2,不一致了
目前负债150多万
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 哪位大虾能帮我分析下这个脚本

#3

帖子 xhy » 2008-11-23 15:31

后面内嵌的也不是什么C语言代码,只是比较像C
目前负债150多万
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

Re: 哪位大虾能帮我分析下这个脚本

#4

帖子 zwjiong » 2008-11-23 15:38

恩 我想分析下其中的过程,他应该通过'pkg-config --modversion glib-2.0读到2.18.0,这个版本是我自己手工安装的,在/usr/local/lib里面,我在终端下面也测试过是2.18.0,应该说明.pc也是找到了。但是我新利得里面装的是2.18.2,我就有问题了,configure是通过什么语句或者哪个环境变量知道我里面还有一个2.18.2的版本,因为据我了解的,程序的依赖性的查找都是通过.pc来实现的,那么我就必须要去读一个2.18.2版本的.pc才能知道版本有冲突,但是我也没有找到新里的安装的2.18.2版本的.pc文件,我是在usr/lib里面找的,新里的应该都装这个路径的把
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

Re: 哪位大虾能帮我分析下这个脚本

#5

帖子 zwjiong » 2008-11-23 15:40

xhy 写了:后面内嵌的也不是什么C语言代码,只是比较像C
应该是C吧,完整的是:
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>

int
main ()
{
int major, minor, micro;
char *tmp_version;

system ("touch conf.glibtest");

/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = g_strdup("$min_glib_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_glib_version");
exit(1);
}

if ((glib_major_version != $glib_config_major_version) ||
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\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);
printf("*** library (version %d.%d.%d)\n",
glib_major_version, glib_minor_version, glib_micro_version);
}
else
{
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)))
{
return 0;
}
else
{
printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
glib_major_version, glib_minor_version, glib_micro_version);
printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
major, minor, micro);
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 哪位大虾能帮我分析下这个脚本

#6

帖子 xhy » 2008-11-23 16:01

还真是C,用$打头变量的C...
目前负债150多万
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

Re: 哪位大虾能帮我分析下这个脚本

#7

帖子 zwjiong » 2008-11-23 16:13

大虾 能不能帮我解释下
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 哪位大虾能帮我分析下这个脚本

#8

帖子 xhy » 2008-11-23 16:21

卸载掉2.18.0

或者configure的时候指定这个path
目前负债150多万
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

Re: 哪位大虾能帮我分析下这个脚本

#9

帖子 zwjiong » 2008-11-23 16:32

我想知道他从那里知道我系统里面有2个glib版本,是通过什么样的操作
zwjiong
帖子: 17
注册时间: 2008-06-28 16:37

Re: 哪位大虾能帮我分析下这个脚本

#10

帖子 zwjiong » 2008-11-24 14:18

问题已经解决了~~~主要是configure里面又去读了glib库文件里面关于版本的全局变量,我之前装了2.18.0没有更新动态库的缓冲区,所以里面应该还是2.18.2的库,结果就冲突了
shaufu
帖子: 1
注册时间: 2009-02-26 10:17

Re: 哪位大虾能帮我分析下这个脚本

#11

帖子 shaufu » 2009-02-26 10:20

能麻烦再请问一下如何更新动态库的缓冲区? 感谢
x_programmer
帖子: 9
注册时间: 2007-10-25 7:20

Re: 哪位大虾能帮我分析下这个脚本

#12

帖子 x_programmer » 2009-04-23 22:53

sudo ldconfig

就可以了 :em04
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 哪位大虾能帮我分析下这个脚本

#13

帖子 jioyo源 » 2009-04-24 2:42

*** to remove the old version of GLib. You may also be able to fix the error
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
回复