QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2948|回复: 4

请教:GTK编译时出错

[复制链接]
发表于 2009-4-4 16:37:27 | 显示全部楼层 |阅读模式
首先说明一下:小弟刚接触GTK.
我装了两个系统在硬盘上:一个windows xp,一个Fedora 8。在windows里的虚拟机上又装了个Fedora(不知道哪个版本)。我编了一GTK程序,在虚拟机上的linux上可以编译运行,但在Fedora 8下却编译不了。
[zz63@zz GTK]$ yum info gtk+
Installed Packages
Name   : gtk+
Arch   : i386
Epoch  : 1
Version: 1.2.10
Release: 59.fc8
Size   : 2.3 M
Repo   : installed
Summary: The GIMP ToolKit


[zz63@zz GTK]$ yum info glib
Installed Packages
Name   : glib
Arch   : i386
Epoch  : 1
Version: 1.2.10
Release: 28.fc8
Size   : 336 k
Repo   : installed
Summary: A library of handy utility functions


出错如下:
[zz63@zz GTK]$ gcc dialog.c -o dialog `pkg-config --cflags --libs gtk+-2.0`
在包含自 /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h:7 的文件中,
                 从 /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:11,
                 从 /usr/lib/glib-2.0/include/glibconfig.h:11,
                 从 /usr/include/glib-2.0/glib/gtypes.h:30,
                 从 /usr/include/glib-2.0/glib/galloca.h:30,
                 从 /usr/include/glib-2.0/glib.h:30,
                 从 /usr/include/gtk-2.0/gdk/gdktypes.h:32,
                 从 /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 从 /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 从 /usr/include/gtk-2.0/gdk/gdk.h:30,
                 从 /usr/include/gtk-2.0/gtk/gtk.h:31,
                 从 dialog.c:1:
/usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:122:61: 错误:limits.h:没有那个文件或目录
在包含自 /usr/include/glib-2.0/glib.h:36 的文件中,
                 从 /usr/include/gtk-2.0/gdk/gdktypes.h:32,
                 从 /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 从 /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 从 /usr/include/gtk-2.0/gdk/gdk.h:30,
                 从 /usr/include/gtk-2.0/gtk/gtk.h:31,
                 从 dialog.c:1:
/usr/include/glib-2.0/glib/gbookmarkfile.h:24:18: 错误:time.h:没有那个文件或目录
In file included from /usr/include/glib-2.0/glib.h:36,
                 from /usr/include/gtk-2.0/gdk/gdktypes.h:32,
                 from /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 from /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 from /usr/include/gtk-2.0/gdk/gdk.h:30,
                 from /usr/include/gtk-2.0/gtk/gtk.h:31,
                 from dialog.c:1:
/usr/include/glib-2.0/glib/gbookmarkfile.h:122: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gbookmarkfile.h:129: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gbookmarkfile.h:148: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gbookmarkfile.h:149: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_bookmark_file_get_added’
/usr/include/glib-2.0/glib/gbookmarkfile.h:154: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gbookmarkfile.h:155: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_bookmark_file_get_modified’
/usr/include/glib-2.0/glib/gbookmarkfile.h:160: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gbookmarkfile.h:161: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_bookmark_file_get_visited’
In file included from /usr/include/glib-2.0/glib.h:41,
                 from /usr/include/gtk-2.0/gdk/gdktypes.h:32,
                 from /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 from /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 from /usr/include/gtk-2.0/gdk/gdk.h:30,
                 from /usr/include/gtk-2.0/gtk/gtk.h:31,
                 from dialog.c:1:
/usr/include/glib-2.0/glib/gdate.h:170: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
/usr/include/glib-2.0/glib/gdate.h:224: 警告:‘struct tm’ 在形参表内部声明
/usr/include/glib-2.0/glib/gdate.h:224: 警告:它的作用域仅限于此定义或声明,这可能并不是您想要的
在包含自 /usr/include/pango-1.0/pango/pango.h:45 的文件中,
                 从 /usr/include/gtk-2.0/gdk/gdktypes.h:33,
                 从 /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 从 /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 从 /usr/include/gtk-2.0/gdk/gdk.h:30,
                 从 /usr/include/gtk-2.0/gtk/gtk.h:31,
                 从 dialog.c:1:
/usr/include/pango-1.0/pango/pango-utils.h:25:19: 错误:stdio.h:没有那个文件或目录
In file included from /usr/include/pango-1.0/pango/pango.h:45,
                 from /usr/include/gtk-2.0/gdk/gdktypes.h:33,
                 from /usr/include/gtk-2.0/gdk/gdkcolor.h:31,
                 from /usr/include/gtk-2.0/gdk/gdkcairo.h:23,
                 from /usr/include/gtk-2.0/gdk/gdk.h:30,
                 from /usr/include/gtk-2.0/gtk/gtk.h:31,
                 from dialog.c:1:
/usr/include/pango-1.0/pango/pango-utils.h:34: 错误:expected ‘)’ before ‘*’ token
In file included from /usr/include/gtk-2.0/gtk/gtkrecentaction.h:26,
                 from /usr/include/gtk-2.0/gtk/gtk.h:146,
                 from dialog.c:1:
/usr/include/gtk-2.0/gtk/gtkrecentmanager.h:180: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gtk_recent_info_get_added’
/usr/include/gtk-2.0/gtk/gtkrecentmanager.h:181: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gtk_recent_info_get_modified’
/usr/include/gtk-2.0/gtk/gtkrecentmanager.h:182: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gtk_recent_info_get_visited’
/usr/include/gtk-2.0/gtk/gtkrecentmanager.h:188: 错误:expected declaration specifiers or ‘...’ before ‘time_t’
[zz63@zz GTK]$

请教高手,我还要安装什么或怎样配置才能在Fedora 8下编译GTK程序?谢谢……
发表于 2009-4-18 02:36:37 | 显示全部楼层
stdio.h都没有, 应该不是GTK的问题了... 你看看/usr/include下有没有stdio.h
回复

使用道具 举报

 楼主| 发表于 2009-4-22 23:07:16 | 显示全部楼层

回复 2# 默难 的帖子

我的代码里面不需要stdio.h,我不要它在终端上输出东西。

今天我重装了一遍系统,现在可以编译GTK程序了,但是还是不知道怎么解决那个问题。
我在网上找了很多,都是说找不到gtk/gtk.h,好像都没有解决问题。

不知道是不是环境变量出了问题,反正我用echo $PATH显示时,没有/usr/include这个路径。
回复

使用道具 举报

发表于 2009-4-23 16:51:50 | 显示全部楼层
原帖由 zz_6_3 于 2009-4-22 23:07 发表
我的代码里面不需要stdio.h,我不要它在终端上输出东西。

今天我重装了一遍系统,现在可以编译GTK程序了,但是还是不知道怎么解决那个问题。
我在网上找了很多,都是说找不到gtk/gtk.h,好像都没有解决问题。

不知道是不是环 ...

你的代码不用不意味着gtk里面不用啊。
include路径不在PATH里面
回复

使用道具 举报

 楼主| 发表于 2009-4-27 22:35:16 | 显示全部楼层
嗯,include确实不在PATH里面,之前说“可能是因为那个include没包含在PATH里面”是在网上看的,后来在重装的系统上又显示了一下PATH,还是没有include,不过重装后的系统能编译GTK。
至于那个stdio.h,我是拿以前能编译的程序重新编译的,没有改代码,以前能编译,也能运行。后来重装系统后就不能编译了。现在又重装系统,又能编译了,还是没改代码。所以应该是不用包含stdio.h。现在就觉得应该是有哪个包没装。

要不你看看代码:
#include <gtk/gtk.h>
GtkWidget *dialog;

gint delete_event(GtkWidget *widget,GdkEvent *event,gpointer data)
{
   gtk_widget_show(dialog);
   return TRUE;
}

gint widgethide(GtkWidget *widget,GdkEvent *event,gpointer data)
{
   gtk_widget_hide(dialog);
   return TRUE;
}

int main(int argc,char *argv[])
{
   GtkWidget *window;
   GtkWidget *button;
   GtkWidget *label;

   gtk_init(&argc,&argv);

   window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width (GTK_CONTAINER (window),200);
   g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(delete_event),NULL);

   dialog=gtk_dialog_new();

   button=gtk_button_new_with_label("YES");
   g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(gtk_main_quit),NULL);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),button,TRUE,FALSE,5);
   gtk_widget_show(button);

   button=gtk_button_new_with_label("NO");
   g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(widgethide),NULL);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),button,TRUE,FALSE,5);
   gtk_widget_show(button);

   label=gtk_label_new("Are you sure to EXIT?");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),label,TRUE,TRUE,0);
   gtk_widget_show(label);

   gtk_widget_show(window);

   gtk_main();

   return 0;
}

谢谢你啊……
这么久还只有你一个人发表意见

[ 本帖最后由 zz_6_3 于 2009-4-27 22:58 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-29 10:00 , Processed in 0.066544 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表