编译平台:x86、VMware上Ubuntu-10.04
目标平台:SOC3210
交叉编译工具链:gcc-3.4.6(mipsel)
一、所需软件包:
1、zlib-1.2.5.tar.bz2
2、freetype‐2.3.5.tar.bz2
3、libpng-1.2.40.tar.bz2
4、jpegsrc.v6b.tar.gz
5、DirectFB-1.3.0.tar.gz
6、DirectFB-examples-1.2.0.tar.gz
7、libtool-1.5.26.tar.gz
8、tiff-3.8.2.tar.gz
9、libxml2-2.7.7.tar.gz
10、expat-2.0.1.tar.gz
11、fontconfig-2.4.2.tar.gz
12、gettext-0.18.1.1.tar.gz
13、glib-2.12.13.tar.gz
14、atk-1.22.0.tar.gz
15、cairo-1.4.10.tar.gz
16、pango-1.16.4.tar.bz2
17、gtk+-2.10.14.tar.bz2
二、编译步骤:
1、搭建交叉编译工具链
$tar zxvf gcc-3.4.6.tgz -C /opt
$export PATH=/opt/gcc-3.4.6/bin:$PATH
如果需要在另外的终端和重启机子后都包含这环境变量的话,可以把/opt/gcc-3.4.6/bin: 添加到/etc/environment文件下,然后打开新终端或重启虚拟机。
2、在终端下输入
$mkdir /usr/directfb-gtk
$export PREFIX=/usr/directfb-gtk
$export LDFLAGS=-L$PREFIX/lib
$export CFLAGS="-g -I$PREFIX/include"
$export CPPFLAGS="-g -I$PREFIX/include"
$export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
3、zlib-1.2.5
$tar jxvf zlib-1.2.5.tar.bz2
$cd zlib-1.2.5
$./configure --prefix=$PREFIX --shared
——不能加“--host=mipsel-linux”,否则出错。
$vi Makefile
——把Makfile里的gcc,ar,ranlib全都替换成mipsel-linux-gcc,mipsel-linux-ar, mipsel-linux-ranlib。
$make
$make install
4、freetype‐2.3.5
$tar jxvf freetype‐2.3.5.tar.bz2
$cd freetype‐2.3.5
$./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=$PREFIX
$make
$make install
5、libpng-1.2.40
$tar jxvf libpng-1.2.40.tar.bz2
$cd libpng-1.2.40
$./configure --host=mipsel-linux --prefix=$PREFIX --with-gnu-ld
$make
$make install
6、jpegsrc.v6b
$tar zxvf jpegsrc.v6b.tar.gz
$cd jpeg-6b
$./configure --host=mipsel-linux --prefix=$PREFIX --enable-shared
$vi Makefile
——把Makefile里的gcc替换成mipsel-linux-gcc
$make
$make install
出错提示:
无法创建普通文件"/usr/directfb/man/man1/cjpeg.1"
参考解决:
mkdir /usr/directfb-gtk/man /usr/directfb-gtk/man/man1
$make install
7、DirectFB-1.3.0
$tar zxvf DirectFB-1.3.0.tar.gz
$cd DirectFB-1.3.0
$./configure --prefix=$PREFIX --host=mipsel-linux --enable-sdl=no --enable-x11=no --enable-jpeg --enable-freetype --enable-png --with-gfxdrivers=none
参考:如果需要关闭jpeg的支持,可以加上--enable-jpeg=no。
这里设置的DirectFB的安装路径是/usr/directfb,那么在目标系统中也必须保证DirectFB是在这样的一个目录中。因为DirectFB编译时已经把这个目录编译到程序中,无法后期设置。
$make
注意:可能会有出错提示
/opt/gcc-3.4.6/bin/../lib/gcc/mipsel-linux/3.4.6/../../../../mipsel-linux/b in/ld: warning: libz.so.1, needed by /usr/directfb/lib/libpng12.so, not found (try using -rpath or -rpath-link)
/usr/directfb/lib/libpng12.so: undefined reference to `deflate'
/usr/directfb/lib/libpng12.so: undefined reference to `inflate'
/usr/directfb/lib/libpng12.so: undefined reference to `inflateInit_'
/usr/directfb/lib/libpng12.so: undefined reference to `crc32'
/usr/directfb/lib/libpng12.so: undefined reference to `deflateInit2_'
/usr/directfb/lib/libpng12.so: undefined reference to `inflateReset'
/usr/directfb/lib/libpng12.so: undefined reference to `deflateReset'
/usr/directfb/lib/libpng12.so: undefined reference to `inflateEnd'
/usr/directfb/lib/libpng12.so: undefined reference to `deflateEnd'
collect2: ld returned 1 exit status
make[2]: *** [directfb-csource] 错误 1
make[2]:正在离开目录 `/******/DirectFB-1.3.0/tools'
参考解决办法:
$cp /usr/directfb-gtk/lib/lib* /opt/gcc-3.4.6/mipsel-linux/lib/
——主要是用第五步的libpng-1.2.40所编译出来的库文件
来更新交叉编译工具链的动态库文件libpng12.so
$make install
8、DirectFB-examples-1.2.0
$tar zxvf DirectFB-examples-1.2.0.tar.gz
$cd DirectFB-examples-1.2.0
$./configure --host=mipsel-linux --prefix=$PREFIX
$make
$make install
9、libtool-1.5.26.tar.gz
./configure --prefix=$PREFIX --host=mipsel-linux
make && make install
10、tiff-3.8.2.tar.gz
./configure --prefix=$PREFIX --build=i686-pc-linux-gnu --host=mipsel-linux
--target=mipsel-linux --enable-jpeg --enable-shared --without-x
make && make install
11、libxml2-2.7.7.tar.gz
./configure --prefix=$PREFIX --host=mipsel-linux
出错提示:
/bin/rm: cannot remove `libtoolT': No such file or directory
Done configuring
vi libtoolT 保存退出。
make && make install
12、expat-2.0.1.tar.gz
./configure --prefix=$PREFIX --host=mipsel-linux
make
make install
13、fontconfig-2.4.2.tar.gz
./configure --prefix=$PREFIX --host=mipsel-linux --target=mipsel-linux --build=i686-pc-linux-gnu --enable-libxml2 --with-arch=mipsel
--with-freetype-config=$PREFIX/bin/freetype-config
make
make install
14、安装本机gettext-0.18.1.1.tar
----为了解决glib依赖库的问题
./configure --prefix=/usr
make&&make install
15、安装本机glib
apt-cache search glib
apt-get install libglib2.0-dev
16、 glib-2.12.13.tar
# echo ac_cv_type_long_long=yes>>mipsel-linux.cache
# echo glib_cv_long_long_format=11>>mipsel-linux.cache
# echo glib_cv_stack_grows=no>>mipsel-linux.cache
# echo glib_cv_uscore=no>>mipsel-linux.cache
# echo ac_cv_func_posix_getpwuid_r=yes>>mipsel-linux.cache
# echo ac_cv_have_abstract_sockets=yes>mipsel-linux.cache
# ./configure --prefix=$PREFIX --cache-file=mipsel-linux.cache
--build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux
如果没有安装本机的gettext可能有出错提示:
checking for msgfmt... no
configure: error:
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
如果没有安装本机glib可能有出错提示
checking for glib-genmarshal... no
configure: error: Could not find a glib-genmarshal in your PATH
make
make install
17、atk-1.22.0.tar
./configure --prefix=$PREFIX --host=mipsel-linux --build=i686-pc-linux-gnu
make
make install
18、cairo-1.4.10.tar.gz
./configure --prefix=$PREFIX --host=mipsel-linux --target=mipsel-linux --enable-directfb --disable-xlib --disable-xlib-xrender --disable-win32 --enable-png --enable-freetype --disable-svg --without-x --enable-pdf --enable-ps
//也可以去掉--enable-pdf --enable-ps
make
make install
19、pango-1.16.4.tar.bz2
Vi configure.in
have_cairo=true
have_cairo_png=true
have_cairo_ps=true
have_cairo_pdf=true
have_cairo_freetype=true
修改/usr/directfb-gtk/lib/pkgconfig中的cairo.pc,在第9行添加一行“Requires : freetype2 fontconfig directfb direct libpng12 fusion libxml-2.0”
./configure --prefix=$PREFIX --host=mipsel-linux --with-arch=mipsel --without-x
--build=i686-pc-linux-gnu --target=mipsel-linux --enable-cairo
可能出错提示:
configure: error: *** Didn't find any of FreeType, X11, ATSUI or Win32.
*** Must have at least one backend to build Pango.
添加:export FREETYPE_CONFIG=$PREFIX/bin/freetype-config
make
make install
19、gtk+-2.10.14.tar.bz2
修改/home/DFB-1.3/lib/pkgconfig中的pangocairo.pc,在第9行Requires里面添加pangoft2
./configure --prefix=$PREFIX --build=i686-pc-linux-gnu --host=mipsel-linux --without-x --with-gdktarget=directfb --with-libpng --with-libtiff --with-libjpeg "LDFLAGS=-L$PREFIX/lib -ltiff -ltiffxx"
版本问题:
vi gdk/directfb/gdkcursor-directfb.c
添加定义
#define __u32 u32
#define __u8 u8
make
可能出错提示:
making all in demos
make[2]: 正在进入目录 `/huang/gtk/gtk+-2.10.14/demos'
no --raw --build-list /
apple_red ./apple-red.png /
gnome_foot ./gnome-foot.png /
> test-inline-pixbufs.h /
|| (rm -f test-inline-pixbufs.h && false)
/bin/bash: no:找不到命令
make[2]: *** [test-inline-pixbufs.h] 错误 1
make[2]:正在离开目录 `/huang/gtk/gtk+-2.10.14/demos'
参考:http://www.docin.com/p-44613303.html 豆丁网
$apt-get install libghc6-gtk-dev
——A GUI library for Haskell (Gtk2Hs) -- GTK+ bindings
-----$apt-get install libgdk-pixbuf2
-----$apt-get install libgdk-pixbuf2-dev 这两安装不了
$vi demos/Makefile
改GDK_PIXBUF_CSOURCE = no
为GDK_PIXBUF_CSOURCE = /usr/bin/gdk-pixbuf-csource
保存退出。
或者安装本机的GTK,也会生成gdk-pixbuf-csource文件。
make
make install
至此交叉编译完成。