免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2447 | 回复: 0
打印 上一主题 下一主题

[zz]Cross-compiling GTK+ over DirectFB [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-22 18:33 |只看该作者 |倒序浏览

This guide explains how to cross-compile GTK+ over DirectFB.
Intro
This guide is based in the wiki
GTK on DirectFB for Embedded Systems
from the
DirectFB
site, but it uses the latest packages available to this date. Since
this procedure has some unstable packages and is still experimental,
it’s not in the mentioned wiki. Hopefully, once this procedure becomes
stable, the wiki will be updated.
I tested this procedure in a STMicroelectronics ST40 processor (SH
architecture). If you’re using this processor, this is the
configuration I have:
  • Board: STB7109 cut 3.0, also called cocoref_gold_7109
  • Linux distribution: STLinux 2.2
  • ST drivers and API: STFAE A16

Warnings
  • This documentation assumes you already have DirectFB install in $PREFIX/usr. Change it accordingly to your installation.
  • This documentation is still a work in progress, some steps of this
    procedure could be useless, ugly and/or dangerous. In order to make
    this procedure easier, it might be that there is the need of some
    patches.
  • The autotools are not very user-friendly when cross-compiling,
    thus, several configure files and Makefile (that are generated by the
    autotools) have to be edited by hand.
  • This procedure uses unstable or development versions of some
    packages like Glib and Cairo. However, the procedure should be the same
    for the latest stable release.
  • GTK+ and all the packages underneath need a considerable amount of
    space and processor. If your embedded device provides a
    hard-drive/compact-flash and supports hardware accelerated graphics you
    can use GTK+ without problems.
    Requirements
    Typically, when developing applications for an embedded system a
    cross-toolchain is needed. If you already have a cross-toolchain you
    don’t have to worry about building it yourself. Otherwise, a well known
    resource for building one is
    http://www.kegel.com/crosstool
    When developing for embedded systems, there are very few Linux
    distributions or packages that contain all the required software for
    building GTK+, therefore you have to build everything from scratch.
    The order in which the packages are compiled is important since some
    of them won’t compile without the others. The packages, their versions
    and the order used for building GTK+ are the following:
    • Glib  from git repository 15/02/08
    • atk-1.20.0
    • freetype-2.3.5
    • zlib-1.2.3
    • libxml2-2.6.30
    • fontconfig-2.5.0
    • libpng-1.2.24
    • Pixmap  from git repository 15/02/08
    • Cairo  from git repository 15/02/08
    • pango-1.19.2
    • gtk+-2.12.3

    Environment configuration
    Suppose that the libraries will be installed in
    /opt/gtkdfb/usr/local (may be /opt/gtkdfb is the root fs of your
    embedded target) and that the cross-toolchain (compiler, linker…) is in
    your path.
    Set the following environment variables that will make our life easier:
    $ export PREFIX=/opt/gtkdfb/usr/local
    $ export LD_LIBRARY_PATH=$PREFIX/lib
    $ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig
    $ export COMPILER=sh4-linux-gcc
    $ export HOST=sh4-linux
    $ export BUILD=i386-linux
    $ export STRIP=sh4-linux-strip

    Building GTK+ and its requirements
    Glib
    Edit the “configure” file:
    Search for the texts “cannot run test program while cross compiling”
    and “cross-compiling”. Remove the following code that appears a couple
    of lines below the searched texts:
    { (exit 1); exit 1; };
    Compile and install:
    $ CC=$COMPILER ./configure –build=$BUILD –host=$HOST –prefix=$PREFIX \
    –disable-selinux –disable-fam –disable-largefile –enable-debug=no –disable-gtk-doc \
    –disable-man
    $ make
    $ make install

    Atk
    Compile and install:
    $ CC=$COMPILER ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX \
    –disable-glibtest –disable-gtk-doc
    $ make
    $ make install

    Freetype
    Compile and install:
    $ CC=$COMPILER ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX
    $ make
    $ make install

    Zlib
    Compile and install:
    $ CC=$COMPILER ./configure –prefix=$PREFIX –shared
    $ make
    $ make install

    libxml2
    Compile and install:
    $ CC=$COMPILER ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX \
    –without-debug
    $ make
    $ make install

    Fontconfig
    Change the value of the flag –with-arch according to your architecture.
    Compile and install:
    $ CC=$COMPILER ./configure –build=$BUILD –host=$HOST –prefix=$PREFIX \
    –with-freetype-config=$PREFIX/bin/freetype-config \
    –enable-libxml2 –with-arch=sh4 –disable-docs
    $ make
    $ make install

    libpng
    Edit the “configure” file:
    Set to ‘yes’ the following variable:
    ac_cv_lib_z_zlibVersion=yes
    Compile and install:
    $ CC=$COMPILER ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX
    $ make
    $ make install

    Pixman
    Compile and install:
    $ CC=$COMPILER ./autogen.sh –host=$HOST –build=$BUILD –prefix=$PREFIX
    $ make
    $ make install

    Cairo
    Compile and install:
    $ CC=$COMPILER \
    directfb_CFLAGS=”-I$PREFIX/../include/directfb” \
    directfb_LIBS=”$PREFIX/../lib/libdirectfb.so \
    $PREFIX/../lib/libdirect.so \
    $PREFIX/../lib/libfusion.so” \
    png_CFLAGS=”-I$PREFIX/include” \
    png_LIBS=$PREFIX/lib/libpng12.so \
    FONTCONFIG_CFLAGS=”-I$PREFIX/include/fontconfig” \
    FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so \
    FREETYPE_CFLAGS=”-I$PREFIX/include/freetype2″ \
    FREETYPE_LIBS=$PREFIX/lib/libfreetype.so \
    ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX \
    –enable-directfb=yes –without-x –disable-xlib –disable-xlib-xrender \
    –disable-win32 –enable-pdf=no –enable-ps=no –enable-png
    $ make
    $ make install

    Pango
    Configure:
    $ CC=$COMPILER \
    GLIB_CFLAGS=”-I$PREFIX/include/glib-2.0 \
    -I$PREFIX/lib/glib-2.0/include” \
    GLIB_LIBS=”$PREFIX/lib/libglib-2.0.so \
    $PREFIX/lib/libgmodule-2.0.so \
    $PREFIX/lib/libgobject-2.0.so \
    $PREFIX/lib/libfontconfig.so \
    $PREFIX/lib/libxml2.so \
    $PREFIX/lib/libfreetype.so” \
    CAIRO_CFLAGS=”-I$PREFIX/include/cairo” \
    CAIRO_LIBS=$PREFIX/lib/libcairo.so \
    FONTCONFIG_CFLAGS=”-I$PREFIX/include/fontconfig” \
    FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so \
    FREETYPE_CFLAGS=”-I$PREFIX/include/freetype2″ \
    FREETYPE_LIBS=$PREFIX/lib/libfreetype.so \
    FREETYPE_CONFIG=$PREFIX/bin/freetype-config \
    ./configure –host=$HOST –build=$BUILD –prefix=$PREFIX \
    –without-x

    Edit the examples/Makefile:
    Add to the GLIB_LIBS variable the following:
    /opt/gtkdfb/usr/local/lib/libpng12.so \
    /opt/gtkdfb/usr/lib/libdirectfb.so \
    /opt/gtkdfb/usr/lib/libdirect.so \
    /opt/gtkdfb/usr/lib/libfusion.so

    Edit the tests/Makefile:
    Set the LIBS variables to the following value:
    LIBS = $(GLIB_LIBS)
    Compile and install:
    $ gmake
    $ gmake install

    GTK+
    Configure:
    $ CC=$COMPILER \
    BASE_DEPENDENCIES_CFLAGS=”-I$PREFIX/include \
    -I$PREFIX/lib/glib-2.0/include -I$PREFIX/include/glib-2.0 \
    -I$PREFIX/include/pango-1.0 \
    -I$PREFIX/include/cairo \
    -I$PREFIX/include/atk-1.0″ \
    BASE_DEPENDENCIES_LIBS=”-L$PREFIX/lib \
    $PREFIX/lib/libglib-2.0.so \
    $PREFIX/lib/libgobject-2.0.so $PREFIX/lib/libgmodule-2.0.so \
    $PREFIX/lib/libfontconfig.so $PREFIX/lib/libxml2.so” \
    GLIB_CFLAGS=”-I$PREFIX/include \
    -I$PREFIX/lib/glib-2.0/include \
    -I$PREFIX/include/glib-2.0″ \
    GLIB_LIBS=”-L$PREFIX/lib \
    $PREFIX/lib/libglib-2.0.so \
    $PREFIX/lib/libgobject-2.0.so \
    $PREFIX/lib/libgmodule-2.0.so \
    $PREFIX/lib/libfontconfig.so \
    $PREFIX/lib/libxml2.so” \
    PANGO_CFLAGS=”-I$PREFIX/include/pango-1.0″ \
    PANGO_LIBS=”-L$PREFIX/lib \
    $PREFIX/lib/libpango-1.0.so \
    $PREFIX/lib/libpangoft2-1.0.so \
    $PREFIX/lib/libpangocairo-1.0.so” \
    GDK_DEP_CFLAGS=”-pthread -I$PREFIX/include/glib-2.0 \
    -I$PREFIX/lib/glib-2.0/include \
    -I$PREFIX/include/pango-1.0 \
    -I$PREFIX/include/cairo \
    -I$PREFIX/include \
    -D_REENTRANT -D_GNU_SOURCE \
    -I$PREFIX/../include \
    -I$PREFIX/../include/directfb” \
    GDK_DEP_LIBS=”-L$PREFIX/lib -lpthread -ldl -lpangocairo-1.0 \
    -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lm \
    $PREFIX/../lib/libdirectfb.so \
    $PREFIX/../lib/libdirect.so \
    $PREFIX/../lib/libfusion.so” \
    GDK_PIXBUF_DEP_CFLAGS=”-pthread -I$PREFIX/include/glib-2.0 \
    -I$PREFIX/lib/glib-2.0/include \
    -I$PREFIX/include \
    -I$PREFIX/../include” \
    GDK_PIXBUF_DEP_LIBS=”-L$PREFIX/lib \
    -lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0 -lpng12 -lm” \
    GTK_DEP_CFLAGS=”-pthread -I$PREFIX/include/glib-2.0 \
    -I$PREFIX/lib/glib-2.0/include \
    -I$PREFIX/include/pango-1.0 \
    -I$PREFIX/include/cairo \
    -I$PREFIX/include -D_REENTRANT -D_GNU_SOURCE \
    -I$PREFIX/../include/directfb \
    -I$PREFIX/include/atk-1.0 \
    -I$PREFIX/../include” \
    GTK_DEP_LIBS=”-L$PREFIX/lib \
    -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 \
    -ldl -lglib-2.0 -lcairo -lpng12 -lm \
    $PREFIX/../lib/libdirectfb.so \
    $PREFIX/../lib/libdirect.so \
    $PREFIX/../lib/libfusion.so” \
    GDK_EXTRA_CFLAGS=”-I$PREFIX/../include” \
    GDK_EXTRA_LIBS=”-L$PREFIX/../lib -lz -lpthread -ldl \
    $PREFIX/../lib/libdirectfb.so \
    $PREFIX/../lib/libdirect.so \
    $PREFIX/../lib/libfusion.so” \
    ./configure \
    –host=$HOST \
    –build=$BUILD \
    –prefix=$PREFIX \
    –with-gdktarget=directfb \
    –without-libtiff \
    –disable-glibtest \
    –disable-largefile \
    –disable-modules \
    –with-included-loaders=gif,jpeg,png,xpm

    Dangerous/ugly step:
    GTK needs a cairo-pdf/ps printing support for compiling, but it’s
    unlikely that PDF/PS will be needed in an embedded system. There is no
    flag to compile it without this setting. There are some patches in
    development to solve this issue, meanwhile it was compiled without the
    cairo-pdf support by doing the following very ugly and dangerous step.
    If you want to add to add PDF/PS support you can try
    Poppler
    .
    Edit the files:
    • gtk/gtkprintoperation.c
    • gtk/gtkprintoperation-unix.c
    • modules/printbackends/lpr/gtkprintbackendlpr.c
    • modules/printbackends/file/gtkprintbackendfile.c

    Comment the lines in all these files that contains the following includes or function calls:
    #include
    #include
    cairo_pdf_surface_set_size()
    cairo_pdf_surface_create()
    cairo_ps_surface_create_for_stream()

    Compile and install:
    $ make
    $ make install

    That’s it.
    Keep in mind that this procedure is still experimental and uses
    unstable versions of Glib and Cairo. In fact, with a stable version of
    Cairo, there’s no need for compiling Pixman because it’s already
    included in Cairo.
    Any help, suggestions and/or ideas are welcome.
    BTW:http://www.paguilar.org/blog/?cat=4


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/70942/showart_1089027.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP