gtk在windows下编程环境的搭建...

老鱼 posted @ 2010年1月31日 01:34 in c/cplusplus , 2500 阅读

首先,gtk是很复杂的库,依赖的东西也多,什么什么pango, glib之类的,如果你在代码中用 #include "gtk/gtk.h" …… 不用make和pkg-config是很难去编译的,当然我是指不用任何ide..只用文本编辑的方式来写的。。。

好了,我忘了从哪里下载了那个一个exe文件就可以安装所有环境的文件了,大概是从gimp那里。。

大概是:
sf的一个站http://sourceforge.net/project /showfiles.php?group_id=98754
我这里下的是 gtk-2.12.9-win32-2.exe
http://downloads.sourceforge.net/gladewin32/gtk-dev-2.12.9-win32-2.exe?modtime=1208660130&big_mirror=0

 

就是下载gtk-dev-x.xx.x-win32-2.exe了。。。

安装到某个目录,然后设置环境变量,好利用make直接编译程序:

GTK_BASEPATH = D:\work\cpp\GTK_DEV\GTK

PATH里加入: %GTK_BASEPATH%\bin;  (因为这样就可以执行pkg-config了)

PKG_CONFIG_PATH = D:\work\cpp\GTK_DEV\GTK\lib\pkgconfig

设置PKG_CONFIG_PATH的路径,指向有那些PC文件的地方。

写一个简单的程序,叫gtk_test1.c吧

 

#include "gtk/gtk.h"

int main(int argc,char *argv[])
{
    GtkWidget *window;
    gtk_init(&argc,&argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show(window);
    gtk_main();
    return 0;
}

写个makefile

 

CC=D:/MinGW/bin/gcc.exe
Gtk1:
    ${CC} Gtk_test.c -o gtk_test1.exe `pkg-config --cflags --libs gtk+-2.0`

 

 

然后make一下:  make gtk1

这样就应该可以了。。。pkg-config那里有个错误,就是cario.pc里面多了一个:

10行:Requires.private: freetype2 >= 9.7.3 fontconfig libpng12 pixman-1 >= 0.10.0

改成

Requires.private: freetype2 >= 9.7.3 fontconfig libpng12

去掉pixman的依赖,就可以了。。。

 

 

Avatar_small
what is a DNS Server 说:
2022年8月10日 03:40

Zen Internet Broadband is considered as the fastest & reliable broadband for both home & business purpose. The company is having the strength of approximately 413 employees & all of them being dedicated & hard working people making the internet services very reliable. ZEN Internet Because of the hard work of the employees as well as CEO (Paul Stobard) & Chairman (Richard Tang), the company won several awards in 2006 at ISPA i.e. Internet Service Provider’s Association.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter