Chinaunix首页 | 论坛 | 博客
  • 博客访问: 357832
  • 博文数量: 100
  • 博客积分: 2500
  • 博客等级: 大尉
  • 技术积分: 1209
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-15 21:24
文章分类

全部博文(100)

文章存档

2011年(100)

分类: C/C++

2011-06-27 15:40:46

Glib概述

Glib是一个底层库,她提供了一系列的的数据类型以及关于这些数据的操作,这些数据类型大概包括:

  • Memory chunks
  • Doubly-linked lists
  • Singly-linked lists
  • Hash tables
  • Strings (which can grow dynamically)
  • String chunks (groups of strings)
  • Arrays (which can grow in size as elements are added)
  • Balanced binary trees
  • N-ary trees
  • Quarks (a two-way association of a string and a unique integer identifier)
  • Keyed data lists (lists of data elements accessible by a string or integer id)
  • Relations and tuples (tables of data which can be indexed on any number of fields)
  • Caches

2:从“Hello world”开始

  1. #include <stdio.h>
  2. #include <glib.h>

  3. int
  4. main(int agrc, char **argv)
  5. {
  6.     g_printf("Hello world!\n");

  7.     return 0;
  8. }

  1. $ gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 -o hello hello.c

  2. $ ./hello

鉴于手工指定库相关信息比较麻烦而且容易出错,大部分的发行版Linux都提供了pkgconfig工具:

  1. $ gcc `pkg-config --cflags --libs glib-2.0` -o hello hello.c

  2. $ ./hello

<参考>

http://developer.gimp.org/api/2.0/glib/index.html

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