求救安装glib库的问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
xiaoquan1
帖子: 4
注册时间: 2010-04-21 0:40

求救安装glib库的问题

#1

帖子 xiaoquan1 » 2010-04-21 1:17

各位走过路过的大侠,小弟今日刚开始学习linux,遇到了glib库的问题,折磨我好些天了。
问题如下:我用的ubuntu9.10,安装的新立德自带的gcc-4.4.1,下载gettext-0.14.5.tar.gz,解压
安装时./configure --prefix=/usr,make,sudo make install显示正确安装。下载glib-2.12.1.tar.bz2,解压安装时./configure --prefix=/usr,make,sudo make install显示正确安装。然后我在myproject目录下用vim编写了一个简单的测试glib库的程序:
#include <stdio.h>
#include <glib.h>
#include <glib/gprintf.h>
void main()
{
gchar ch[128];
g_sprintf(ch, "hello world");
}
但我在用gcc编译时:
$ gcc -o test test.c,提示没有glib.h和gprintf.h文件和目录
然后我用如下编译
$gcc test.c -I/usr/include/glib-2.0 -L/usr/lib/glib-2.0 -o test,却又冒出很多错误,最后部分截图如下:
图片


最后即使我在重装glib库也是这样的错误,头都大了,希望有高手能帮我解答一下,谢谢了!
头像
goldfox_79
帖子: 2004
注册时间: 2005-10-16 8:26
来自: 地球

Re: 求救安装glib库的问题

#2

帖子 goldfox_79 » 2010-04-21 8:41

“此图片来自QQ空间,未经允许不可引用”

直接把图片上传到论坛把,链接看不了
xiaoquan1
帖子: 4
注册时间: 2010-04-21 0:40

Re: 求救安装glib库的问题

#3

帖子 xiaoquan1 » 2010-04-21 10:18

谢谢楼上关心,第一次发帖,还不知道规矩,以为预览有了就有了。

.............
/usr/include/glib-2.0/glib/gtree.h:77: error: expected ‘)’ before ‘*’ token
/usr/include/glib-2.0/glib/gtree.h:80: error: expected ‘)’ before ‘*’ token
/usr/include/glib-2.0/glib/gtree.h:81: error: expected ‘)’ before ‘*’ token
In file included from test.c:3:
/usr/include/glib-2.0/glib/gprintf.h:28: error: expected ‘)’ before ‘const’
/usr/include/glib-2.0/glib/gprintf.h:31: error: expected declaration spec
/usr/include/glib-2.0/glib/gprintf.h:32: error: format string argument not a string type
/usr/include/glib-2.0/glib/gprintf.h:33: error: expected ‘)’ before ‘*’ token
/usr/include/glib-2.0/glib/gprintf.h:37: error: expected ‘)’ before ‘const’
/usr/include/glib-2.0/glib/gprintf.h:40: error: expected declaration specifiers or ‘...’ before ‘gchar’
/usr/include/glib-2.0/glib/gprintf.h:41: error: expected declaration specifiers or
/usr/include/glib-2.0/glib/gprintf.h:42: error: expected ‘)’ before ‘*’ token
/usr/include/glib-2.0/glib/gprintf.h:45: error: expected ‘)’ before ‘*’ token
test.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/include/glib-2.0/glib/gmem.h:47: error: old-style parameter declarations in prototyped function definition
test.c:9:error: expected ‘{’ at end of in:42:7

这是运行 $gcc -o test test.c -L/usr/lib/glib -I/usr/include/glib-2.0后错误提示最后一部分结果。
安装glib库时是用的./configure --prefix=/usr,安装完后,在/usr/lib/目录下有个glib-2.0的文件夹,该文件夹里只有一个一个include文件夹,include的文件夹里只有一个glibconfig.h文件。在/usr/include/文件夹里也有一个glib-2.0的文件夹glib.h等头文件。我现在怀疑的是我的glib库是否真的安装上了,但我也不知道怎么判断。希望楼上能帮忙解释一下,谢谢了。
回复