一步一步搭建GTK-DFB 开发环境
Jiazhen<luojiazhen#gmail.com>
0. 概要
GTK-DFB 环境存在于GDK 库中,它整合了GTK+ 工具集和DirectFB 视窗系统,就像GTK-X11 整合了GTK 和X11 ,GDK-WIN32 也起到了Windows GDI 一样的作用。GTK-DFB 主要面向嵌入式应用程序,而不是桌面应用程序。它不具备像X11 或者GDK-WIN32 那样全面的功能,却也足够开发复杂的应用程序,比如Linux 下的画图工具GIMP 。
下面主要介绍GTK-DFB 开发环境的搭建。
※注意:
这里可以将GTKDFB 安装到/usr/local/dfb 目录下面,以免和系统中已经存在的X11 和DFB 应用程序相冲突。GTKDFB 的运行依赖于以下开发库:
jpeg libpng pkg-config gettext glib atk freetype DirectFB
libexpat fontconfig pixman cairo pango gtk libIDL
※准备:
需要创建以下目录
- mkdir /usr/local/dfb
- mkdir -p /usr/local/dfb/man/man1
- mkdir /usr/local/dfb/bin
- mkdir /usr/local/dfb/lib
- mkdir /usr/local/dfb/etc
- mkdir /usr/local/dfb/include
- mkdir /usr/local/dfb/info
- mkdir /usr/local/dfb/sbin
- mkdir /usr/local/dfb/share
- mkdir /usr/local/dfb/src
在终端设置以下的环境变量,也可以写成脚本文件,如/root/export.sh
#!/bin/bash
export LD_LIBRARY_PATH=/usr/local/dfb/lib
export PATH=/usr/local/dfb/bin/:$PATH
export PKG_CONFIG_PATH=/usr/local/dfb/lib/pkgconfig
每次打开终端只需执行
#source /root/export.sh
1. GTK-DFB 环境搭建
以下是我们需要安装的开发包,有详细的下载地址。有些版本可能有更新。希望尝试不同版本,碰到不同问题的人们,能够跟进补充。这里介绍的是已经测试通过的情况。
1.1 安装jpeg
- Package Name: jpegsrc.v6b.tar.gz
- Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/jpegsrc.v6b.tar.gz
- Installation:
- tar -xzvf jpegsrc.v6b.tar.gz
- cd jpeg-6b
- ./configure --prefix=/usr/local/dfb --without-x --enable-shared --without-libjasper
- make
- make install
1.2. 安装tiff
- Package Name: tiff-3.7.4.tar.gz
- Download URL: ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/tiff-3.7.4.tar.gz
- Installation:
- tar zxvf tiff-3.7.4.tar.gz
- cd tiff-3.7.4
- ./configure --prefix=/usr/local/dfb --without-x
- make
- make install
1.3 安装libpng
- Package Name: libpng-1.2.29.tar.bz2
- Download URL: http://internap.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.29.tar.bz2
- Installation:
- tar jxvf libpng-1.2.29.tar.bz2
- cd libpng-1.2.29
- cp ./scripts/makefile.linux ./Makefile
- Change “prefix=/usr/local” to “prefix=/usr/local/dfb” (line no 31) in Makefile manually
- make
- make install
1.4 安装pkg-config [edit ]
- Package Name: pkg-config-0.22.tar.gz
- Download URL: http://pkgconfig.freedesktop.org/releases/pkg-config-0.22.tar.gz
- Installation:
- tar zxvf pkg-config-0.22.tar.gz
- cd pkg-config-0.22
- ./configure --prefix=/usr/local/dfb --without-x
- make
- make install
1.5 安装gettext
- Package Name: gettext-0.17.tar.gz
- Download URL: http://ftp.gnu.org/gnu/gettext/
- Installation:
- tar zxvf gettext-0.17.tar.gz
- cd gettext-0.17
- ./configure --prefix=/usr/local/dfb
- make
- make install
Note: This package might not be required.
1.6 安装glib [edit ]
- Package Name: glib-2.16.3.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/glib/2.16/glib-2.16.3.tar.bz2
- Installation:
- tar jxvf glib-2.16.3.tar.bz2
- cd glib-2.16.3
- ./configure --prefix=/usr/local/dfb
- make
- make install
1.7 安装atk [edit ]
- Package Name: atk-1.13.2.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/atk/1.13/atk-1.13.2.tar.bz2
- Installation
- tar jxvf atk-1.13.2.tar.bz2
- cd atk-1.13.2
- ./configure --prefix=/usr/local/dfb
- make
- make install
1.8 安装freetype [edit ]
- Package Name: freetype-2.3.5.tar.bz2
- Download URL: http://superb-east.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.5.tar.bz2
- Installation:
- tar jxvf freetype-2.3.5.tar.bz2
- cd freetype-2.3.5
- ./configure --prefix=/usr/local/dfb --without-x --enable-directfb --disable-xlib --disable-win32
- make
- make install
1.9 安装DirectFB [edit ]
- Package Name: DirectFB-1.1.1.tar.gz
- Patches: Download following patches and apply to the source.
- 001-dfb-dok-list-crash-fix.patch
- Download URL: http://www.directfb.org/downloads/Core/DirectFB-1.1.1.tar.gz
- Installation:
- apt-get install libsdl1.2-dev
- tar zxvf DirectFB-1.1.1.tar.gz
- cd DirectFB-1.1.1
- ./configure --prefix=/usr/local/dfb --enable-sdl
- make
- make install
After installing DirectFB, set it up to run over SDL on X11.
- Create .directfbrc under home directory.
- Add following lines to .directfbrc
- wm=default
- mode=800x600
- depth=32
- system=sdl
- As root user, run the following command
- touch /usr/local/dfb/lib/libgdk-x11-2.0.so.0
1.10 安装libexpat
- Package Name: expat-2.0.1.tar.gz
- Download URL: http://expat.sourceforge.net/
- Installation:
- tar zxvf expat-2.0.1.tar.gz
- cd expat-2.0.1
- ./configure --prefix=/usr/local/dfb
- make
- make install
1.11 安装fontconfig
- Package Name: fontconfig-2.4.91.tar.gz
- Download URL: http://www.fontconfig.org/release/fontconfig-2.4.91.tar.gz
- Installation:
- tar fontconfig-2.4.91.tar.gz
- cd fontconfig-2.4.91
- ./configure --prefix=/usr/local/dfb --without-x --enable-directfb --disable-xlib --disable-win32
- make
- make install
1.12 安装pixman
- Package Name: pixman-0.10.0.tar.gz
- Download URL: http://www.cairographics.org/releases/pixman-0.10.0.tar.gz
- Installation:
- tar -zxvf pixman-0.10.0.tar.gz
- cd pixman-0.10.0
- ./configure --prefix=/usr/local/dfb
- make
- make install
1.13 安装cairo
- Package Name: cairo-1.6.4.tar.gz
- Download URL: http://www.cairographics.org/releases/cairo-1.6.4.tar.gz
- Patches: Download following patches and apply to the source.
- 001-cairo_dfb-run-clipped-function.patch
- 002-cairo_dfb-dest-image-clip.patch
- 003-cairo_dfb-zero-box-clip-fix.patch
- 004-cairo-blit-optimization.patch
- 005-cairo-font-crash-fix.patch
- Installation:
- tar -zxvf cairo-1.6.4.tar.gz
- cd cairo-1.6.4
- ./configure --prefix=/usr/local/dfb --enable-directfb=yes --enable-xlib=no --enable-xlib-xrender=no --enable-xcb=no --without-x --disable-win32
- make
- make install
1.14 安装pango
- Package Name: pango-1.20.2.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/pango/1.20/pango-1.20.2.tar.bz2
- Installation:
- tar jxvf pango-1.20.2.tar.bz2
- cd pango-1.20.2
- ./configure --prefix=/usr/local/dfb --enable-cairo --without-x --disable-xlib --disable-win32
- make
- make install
1.15 安装gtk
- Package Name: gtk+-2.12.9.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/gtk+/2.12/gtk+-2.12.9.tar.bz2
- Patches: Download the following patch and apply to the source.
- 001-gtk+-2.12.9-dok4.patch
- 002-gtk+-2.12.9-gdkkeys_fix.patch
- 003-gtk+-2.12.9-dok-scroll-experimental.patch
- 004-gtk+-2.12.9-dok-visual-fix.patch
- 005-gtk+-2.12.9-dok-event-block-fix.patch
- 006-gtk+-2.12.9-dok-set-default-display-fix.patch
- 007-gtk+-2.12.9-dok-set-focus-fixes.patch
- Installation:
- tar jxvf gtk+-2.12.9.tar.bz2
- cd gtk+-2.12.9
- ./configure --prefix=/usr/local/dfb --with-gdktarget=directfb --without-x
- make
- make install
1.16 安装libIDL
- Package Name: libIDL-0.8.5.tar.bz2
- Download URL: http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.5.tar.bz2
- Installation:
- tar jxvf libIDL-0.8.5.tar.bz2
- cd libIDL-0.8.5
- apt-get install flex
- apt-get install bison
- ./configure --prefix=/usr/local/dfb
- make
- make install
2 .测试GTK-DFB 环境
首先设置环境变量,如果之前写好了脚本export.sh 可以在终端直接执行:
#source export.sh
或者一步一步执行:
#export LD_LIBRARY_PATH=/usr/local/dfb/lib
#export PATH=/usr/local/dfb/bin/:$PATH
#export PKG_CONFIG_PATH=/usr/local/dfb/lib/pkgconfig
之前安装了GTK 开发包,默认情况下,它自动编译了示例程序,这里可以直接运行:
#/usr/local/dfb/bin/gtk-demo
正常的话,就会看见在蓝色(也可能是别的颜色)的背景下弹出GTK 窗口。会发现GTK 窗口的边框消失了,看不见标题栏,最大化及最小化按钮了。这是因为没有用到到窗口管理器。但是DFB 提供了一些简单的消息处理。
Meta + Mouse 可以移动窗口
Meta + C 可以关闭窗口
Meta + X + Mousr Movement 可以改变窗口的层叠顺序
提示:Meta 键就是我们常说的Windows 键,键盘上那个带Windows 图标的就是。
3 . 小结
以上是GTK-DFB 环境的搭建和简单测试。因为开源软件的更新和维护非常的频繁,所以我们需要注意到各个版本的更新,有时候需要及时打上补丁。当然最快捷的方式依照前人实际测试通过的环境来进行。
为了进一步熟悉环境,我们可以尝试运行GIMP,Mozilla-dfb 等经典应用实例。