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:
- 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:
- 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:
- 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 []
- Package Name: pkg-config-0.22.tar.gz
- Download URL:
- 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:
- 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 []
- Package Name: glib-2.16.3.tar.bz2
- Download URL:
- 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 []
- Package Name: atk-1.13.2.tar.bz2
- Download URL:
- 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 []
- Package Name: freetype-2.3.5.tar.bz2
- Download URL:
- 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 []
- Package Name: DirectFB-1.1.1.tar.gz
- Patches: Download following patches and apply to the source.
- Download URL:
- 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:
- 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:
- 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:
- 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:
- Patches: Download following patches and apply to the source.
- 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:
- 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:
- Patches: Download the following patch and apply to the source.
- 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:
- 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等经典应用实例。
阅读(848) | 评论(1) | 转发(0) |