Chinaunix首页 | 论坛 | 博客
  • 博客访问: 102727
  • 博文数量: 35
  • 博客积分: 637
  • 博客等级: 上士
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-15 17:22
文章分类

全部博文(35)

文章存档

2015年(6)

2014年(1)

2013年(3)

2012年(25)

我的朋友

分类: LINUX

2012-10-08 09:07:15

To compile use:

gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` \

`pkg-config --libs gtk+-2.0`

This uses the program pkg-config, which can be obtained from . This program reads the .pc which comes with GTK to determine what compiler switches are needed to compile programs that use GTK. pkg-config --cflags gtk+-2.0 will output a list of include directories for the compiler to look in, and pkg-config --libs gtk+-2.0 will output the list of libraries for the compiler to link with and the directories to find them in. In the above example they could have been combined into a single instance, such as pkg-config --cflags --libs gtk+-2.0.

Note that the type of single quote used in the compile command above is significant.

The libraries that are usually linked in are:

  • The GTK library (-lgtk), the widget library, based on top of GDK.

  • The GDK library (-lgdk), the Xlib wrapper.

  • The gdk-pixbuf library (-lgdk_pixbuf), the image manipulation library.

  • The Pango library (-lpango) for internationalized text.

  • The gobject library (-lgobject), containing the type system on which GTK is based.

  • The gmodule library (-lgmodule), which is used to load run time extensions.

  • The GLib library (-lglib), containing miscellaneous functions; only g_print() is used in this particular example. GTK is built on top of GLib so you will always require this library. See the section on GLib for details.

  • The Xlib library (-lX11) which is used by GDK.

  • The Xext library (-lXext). This contains code for shared memory pixmaps and other X extensions.

  • The math library (-lm). This is used by GTK for various purposes.

阅读(1002) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~