在Windows上安装GTK2

1.首先下载GTK-Runtime-Environment(http://prdownloads.sourceforge.net/gtk-win/GTK-Runtime-Environment-2.2.4-3.exe),安装到D:/Program/GTK2/Runtime目录下。

 

2.然后下载GTK-Development-Environment(http://prdownloads.sourceforge.net/gtk-win/GTK-Development-Environment-2.2.4-3.exe),安装到D:/Program/GTK2/DevEnv目录下。

 

3.再下载DevCPP(http://61.163.92.167:82/down/WY_DEVCPP_5B0905.zip),安装到D:/Program/DEV-CPP目录下。

 

4.右键 “我的电脑”- “属性”- “环境变量”- “系统变量”- 选中“Path” -“编辑”- 在前边加上“D:/Program/GTK2/Runtime/bin;D:/Program/GTK2/Runtime/lib;“

 

5.打开DevCPP,在“工具->编译选项->目录->库”,加入D:/Program/GTK2/DevEnv/lib。

 

6.“工程->工程属性->参数” 或 “工具->编译选项”中的链接器框里面填入:-lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv ,并选中。

 

7.工具->编译选项加上 -mms-bitfields,并选中。

 

8. “工具->编译选项->目录->C包含文件”加上:
D:/Program/GTK2/DevEnv/include/atk-1.0
D:/Program/GTK2/DevEnv/include/glib-2.0
D:/Program/GTK2/DevEnv/include/gtk-2.0
D:/Program/GTK2/DevEnv/include/pango-1.0
D:/Program/GTK2/DevEnv/lib/gtk-2.0/include
D:/Program/GTK2/DevEnv/lib/glib-2.0/include

9.在DevCPP中新建一个工程,在main.c中:

 #include int main(int argc,char *argv[]) { GtkWidget *window; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "My GTK2"); gtk_widget_show (window); gtk_main (); return 0; }

 

 运行便可以看到一个简单的窗口了。

 

参考:http://www.linuxsir.org/bbs/printthread.php?t=162131

你可能感兴趣的:(Linux)