Wednesday, July 27, 2011

GTK+ DirectFB cross compilation

GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets. GTK+ is suitable for projects ranging from small one-off tools to complete application suites.

I have download the below softwares to start with.
atk-1.30.0: http://ftp.gnome.org/pub/GNOME/sources/atk/1.30/atk-1.30.0.tar.bz2

cairo-1.8.10: http://cairographics.org/releases/cairo-1.8.10.tar.gz

DirectFB-1.4.3: http://directfb.org/downloads/Core/DirectFB-1.4/DirectFB-1.4.3.tar.gz

expat-2.0.1: http://sourceforge.net/projects/expat/

fontconfig-2.8.0: http://fontconfig.org/release/fontconfig-2.8.0.tar.gz

freetype-2.3.12: http://sourceforge.net/projects/freetype/files/

glib-2.24.0: http://ftp.gnome.org/pub/gnome/sources/glib/2.24/glib-2.24.0.tar.bz2

gtk+-2.20.1: http://ftp.gnome.org/pub/gnome/sources/gtk+/2.20/gtk+-2.20.1.tar.bz2

jpeg-8b: http://www.ijg.org/files/jpegsrc.v8b.tar.gz

tslib: http://www.zelow.no/floppyfw/download/Development/src/

libpng-1.2.39: http://sourceforge.net/projects/libpng/files/

libxml2-2.7.7: ftp://gd.tuwien.ac.at/pub/libxml/libxml2-2.7.7.tar.gz

pango-1.28.1: http://ftp.gnome.org/pub/gnome/sources/pango/1.28/pango-1.28.1.tar.bz2

pixman-0.18.2: http://cairographics.org/releases/pixman-0.18.2.tar.gz

tiff-3.9.2: http://download.osgeo.org/libtiff/tiff-3.9.2.tar.gz

zlib-1.2.5: http://zlib.net/zlib-1.2.5.tar.gz


With scratchbox2 and qemu on the host machine cross compiling was straightforward.

Cross compiling order

1) tslib
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

2) zlib
since glib require zlib
sb2 ./configure --prefix=/opt/gtkfb --shared
sb2 make install

3) glib
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-static --with-html-dir=/tmp/dump
sb2 make install

4) atk
export PKG_CONFIG_PATH=/opt/gtkfb/lib/pkgconfig
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-glibtest
sb2 make install

5) jpeg-8b
sb2 ./configure --prefix=/opt/gtkfb --enable-shared --enable-static
sb2 make install

6) libpng
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

7) expat-2.0
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

8) freetype
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

9)libxml
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --without-python
sb2 make install

10)freetype-2.3.12
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --with-freetype-config=/opt/gtkfb/bin/freetype-config

11) tiff -- not used gcc 4.3.2
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --enable-shared
sb2 make install

12) DirectFB
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --with-gfxdrivers=none --with-inputdrivers=all --enable-png --enable-jpeg --enable-tiff=no --enable-zlib --enable-sdl=no --enable-gif=no --disable-x11
sb2 make install

13) pixman-0.18.2
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-gtk

14) cairo
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --without-x --disable-xlib --disable-xlib-xrender --enable-directfb --enable-freetype --disable-win32 --enable-pdf --enable-ps --enable-svg --enable-png

15) Pango
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --without-x

16 gtk
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --with-gdktarget=directfb --without-x --without-libtiff --disable-glibtest --disable-cups

Now to compile a simple helloworld.c pro-gramme with these libraries.
export PKG_CONFIG_PATH=/opt/gtkfb/lib/pkgconfig
arm-linux-gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` -Wl,-O1 -Wl,-rpath,/opt/gtkfb/lib

6 comments:

  1. Hi Folks,

    I am ported gtk-2.20 on DirectFb 1.4.3. After porting gtk, all basic app functionalities are working good.

    But when I use
    area = gtk_drawing_area_new();

    gtk_widget_set_size_request(area, 10, 10);
    gdk_color_parse( "red" /*SCREEN_BG_COLOR*/, &color )
    gtk_widget_modify_bg (area, GTK_STATE_NORMAL, &color);

    gtk_box_pack_start (GTK_BOX (hUpch1box), area, TRUE, TRUE, 0);

    gtk_widget_show_all(window);

    gtk is crashing with cairo surface create.

    1. Crashing is because cairo_directfb_surface_create() s failing while accessing Directfb surface.

    Please help me in this regards.
    Thanks in advance,
    Regards,
    Rajesh

    ReplyDelete
  2. Deatailed Logs:
    Code is Crashing at

    dfbsurface->AddRef (dfbsurface); API in below API.

    file : cairo-directfb-surface.c
    API: cairo_surface_t * cairo_directfb_surface_create (IDirectFB *dfb, IDirectFBSurface *dfbsurface)
    {
    cairo_directfb_surface_t *surface;
    DFBSurfacePixelFormat format;
    DFBSurfaceCapabilities caps;
    D_ASSERT (dfb != NULL);
    D_ASSERT (dfbsurface != NULL);

    cairo_directfb_surface_backend_init (dfb);

    surface = calloc (1, sizeof (cairo_directfb_surface_t));
    if (surface == NULL)
    {
    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
    }

    printf("%s,%s, %d \n ", __FILE__, __FUNCTION__, __LINE__ );
    /* code is crashing here */
    dfbsurface->AddRef (dfbsurface);
    dfbsurface->GetPixelFormat (dfbsurface, &format);
    dfbsurface->GetSize (dfbsurface, &surface->width, &surface->height);
    surface->dfb = dfb;
    surface->dfbsurface = dfbsurface;
    surface->format = _directfb_to_cairo_format (format);
    surface->content = _directfb_format_to_content (format);

    dfbsurface->GetCapabilities (dfbsurface, &caps);
    if (caps & DSCAPS_PREMULTIPLIED)
    surface->blit_premultiplied = TRUE;
    _cairo_surface_init (&surface->base, &_cairo_directfb_surface_backend, surface->content);
    return &surface->base;
    }

    code crashing here:
    dfbsurface->AddRef (dfbsurface);

    Please help me in this issue..

    Thanks in advance,

    Regards,

    ReplyDelete
  3. i can't install tslib , i have an error :

    dautronghien@DAUTRONGHIEN:/scratchbox/tool for linux/tslib$ ls
    acinclude.m4 autogen.sh COPYING INSTALL NEWS src
    AUTHORS ChangeLog CVS m4 plugins tests
    autogen-clean.sh configure.ac etc Makefile.am README tslib.pc.in
    dautronghien@DAUTRONGHIEN:/scratchbox/tool for linux/tslib$ ./autogen.sh
    autoreconf: `configure.ac' or `configure.in' is required
    dautronghien@DAUTRONGHIEN:/scratchbox/tool for linux/tslib$


    may you help me ? thanks!

    ReplyDelete
  4. Hi..
    I am new to Linux and Cross compilation
    I downloaded all those mentioned here...and when I try the first syntax,its giving an error

    "sb2: Error: No target specified and none set as default, aborting."

    Please help me with this..

    Thanks in advance !!
    subhashini

    ReplyDelete
  5. i am facing libgtk-directfb-2.0.so when searching for -lgtk-directfb-2.0 issue when compile application.after success all the given spates.

    ReplyDelete
  6. I have install successfully all the above packages. and test application. then facing error "libgtk-directfb-2.0.so when searching for -lgtk-directfb-2.0" when compile application.

    ReplyDelete