引用参考:
http://www.cs.ccu.edu.tw/~chm91u/site/gtk_for_win32.php
在VC++6.0,C++BuilderX,Dev-C++,MinGWstudio下同步配置gtk开发环境,MinGWstudio(一下简称MGS)先出来了,现将配置步骤罗列如下:
1.设置系统变量home,任意目录(注:仅为建议)仅为建议)
2.下载所需环境: http://www.pcpm.ucl.ac.be/~gustin/win32_ports/ 下哪个几个,以什么为准呢?我是全部下载的 有点笨 确实没有办法,不过有几个包必须要下:gettext,glib,pkgconfig,gtk+,pango,atk.
3.解压缩到某个文件夹 假定d:\gnu 最终形成诸如:bin,dll,etc,include,manshare等若干文件夹 我添加了个package包,放置那些下载的但是还没有使用的包
4.配置MDS:
找到[RecentProject]行, 在它的上一行添加
Directories_Include_1=D:\gnu\include
Directories_Include_2=D:\MinGWStudio\MinGW\include
Directories_Include_3=D:\gnu\include\gtk-2.0
Directories_Include_4=D:\gnu\include\glib-2.0
Directories_Include_5=D:\gnu\lib\glib-2.0\include
Directories_Include_6=D:\gnu\lib\gtk-2.0\include
Directories_Include_7=D:\gnu\include\pango-1.0
Directories_Include_8=D:\gnu\include\atk-1.0
Directories_Lib_1=D:\gnu\lib
Directories_Lib_2=D:\gnu\dll
Directories_Lib_3=D:\gnu\lib\pkgconfig
Directories_Lib_4=D:\gnu\lib\pango\1.4.0\modules
这里假定您的MSD没有进行过配置.其实这里是设置include directiories的地方,也可以从Edit/Options/Directions中改变.
5.测试:
新建工程hellogtk,创建C++文件mian.cpp
#include <gtk/gtk.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
GtkWidget *win, *label;
gtk_set_locale();
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(GTK_WIDGET(win), 200, 100);
gtk_window_set_title(GTK_WINDOW(win), "Test");
gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(gtk_exit), NULL);
label=gtk_label_new("Hello, GTK+\n");
gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(label));
gtk_widget_show_all(win);
gtk_main();
return 0;
}
如果发现有错误提示,一定是您的环境设置不正确