下载DirectFB与样例的源码包:
http://directfb.org/index.php?path=Main%2FDownloads
http://directfb.org/index.php?path=Main%2FDownloads&page=1
一、安装DirectFB
(1)解压安装
$sudo tar zxvf DirectFB-1.6.1.tar.gz
(2)安装
$cd DirectFB-1.6.1
$./configure
注:如果在./configure这步出现下面的提示:
PNG support is missing - many applications won't work correctly!
JPEG support is missing - many applications won't workcorrectly!
FreeType2 support is missing - many applications won't workcorrectly!
参考解决方法:
$apt-cache search libpng
$apt-get install libpng12-dev
$apt-cache search libjpeg
$apt-get install libjpeg62-dev
$apt-cache search libfreetype
$apt-get install libfreetype6-dev
apt-get install libfreetype
注:安装上述包后还需在再配置 $ ./configure
$sudomake
$sudomake install
二、安装DirectFB-examples-1.2.0
(1)下载解压
$sudotar zxvf DirectFB-examples-1.2.0.tar.gz
(2)安装
A:更新数据库
root@/home/dyf/DirectFB-1.6.1#updatedb
B:找到directfb.pc的路径,让其能找到对应的directfb
root@/home/dyf/DirectFB-1.6.1#locate directfb.pc
/home/dyf/DirectFB-1.6.1/directfb.pc
/home/dyf/DirectFB-1.6.1/directfb.pc.in
/root/DirectFB-1.6.1/directfb.pc.in
/usr/local/lib/pkgconfig/directfb.pc
C:设置环境
将上一步得到的pkgconfig库目录加入环境之中:
$export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
(这样只能在当前终端可以运行,关机后还得自已运行些命令,才能运行dfb程序,如 要永久性加入可这样:
可以$sudo vim /root/.profile中加入:PKG_CONFIG_PATH=/usr/local/lib/pkgconfig )
D:安装
$./configure
$ sudo make
$ sudo make install
E: 指定directfb的库目录
$ sudo vim /etc/ld.so.conf 在最后一行加入:/usr/local/lib,保存退出。
$ldconfig
F:运行测试样例
# cdDirectFB-examples-1.6.0/src
$sudodf_andi
如果没有通过且出现错误提示:
~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.6.1|~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) 2001-2012 The world wide DirectFB Open Source Community
(c) 2000-2004 Convergence (integrated media) GmbH
----------------------------------------------------------------
(*)DirectFB/Core: Single Application Core. (2012-08-08 07:26)
(*)Direct/Thread: Started 'Fusion Dispatch' (-1) [MESSAGING OTHER/OTHER 0/0]<8388608>...
(!)Direct/Util: Opening '/dev/fb0' and '/dev/fb/0' failed!
--> The specified file has not beenfound
(!)DirectFB/FBDev: Error opening framebuffer device!
(!)DirectFB/FBDev: Use 'fbdev' option or set FRAMEBUFFER environment variable.
(!)DirectFB/Core: Could not initialize 'system_core' core!
--> A general initialization erroroccured
df_andi.c<472>:
(#) DirectFBError [DirectFBCreate( &dfb )]: A generalinitialization error occured
上面过程中可能出现framebuffer没有启动的问题,需要在ubuntu中配置以让其启动framebuffer支持。
方法:
在当前用户的主目录下(如以root身份登录的则是/root/)建立一个文件:.directfbrc,然后将如
下内容添加到该文件中:
最后,保存退出,这下再运行程序就可以看到程序正常运行了!
mode=1024x768
wm=default
depth=32
system=x11
注:
如果没有安装x11则需要安装
$ apt-get install xorg-dev
编译DFB程序的方法类似于:
gcc -I/usr/local/include -I/usr/local/include/directfb-I/usr/local/include/directfb-internal -L/usr/local/lib -ldirectfb -lpthread-ldl -lz test.c -o test