{"id":11,"date":"2008-07-28T13:42:10","date_gmt":"2008-07-28T12:42:10","guid":{"rendered":"http:\/\/paguilar.org\/?p=11"},"modified":"2008-07-28T13:42:10","modified_gmt":"2008-07-28T12:42:10","slug":"cross-compiling-gtk-over-directfb-v02","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=11","title":{"rendered":"Cross-compiling GTK+ over DirectFB v0.2"},"content":{"rendered":"<p><font size=\"4\"><br \/>\n<strong>Intro <\/strong><br \/>\n<\/font><\/p>\n<p>This guide is based in the wiki <a href=\"http:\/\/www.directfb.org\/wiki\/index.php\/Projects:GTK_on_DirectFB_for_Embedded_Systems\"> GTK on DirectFB for Embedded Systems<\/a> from the <a href=\"http:\/\/www.directfb.org\/\">DirectFB<\/a> site, but it uses the latest packages available to this date. The <a href=\"https:\/\/paguilar.org\/?p=6\" title=\"GTk+ over DirectFB v0.1\">first version<\/a> of this guide used some unstable packages whilst this version uses only stable ones, but since I haven&#8217;t been\u00a0 to test it properly this guide is not present in mentioned wiki. Hopefully, once this procedure becomes stable and tested a bit more, the wiki will be updated.<\/p>\n<p>I tested this procedure in a STMicroelectronics ST40 processor (SH architecture). If you&#8217;re using this processor, this is the configuration I have:<\/p>\n<ul>\n<li>Board: STB7109 cut 3.0, also called cocoref_gold_7109<\/li>\n<li>Linux distribution: STLinux 2.2<\/li>\n<li>DirectFB driver: stgfb-3.0_stm23_0008-4<\/li>\n<\/ul>\n<p><font size=\"4\"><br \/>\n<strong>Warnings<\/strong><br \/>\n<\/font><\/p>\n<ol>\n<li> This documentation assumes you already have DirectFB install in $PREFIX\/usr. Change it accordingly to your installation.<\/li>\n<li>This documentation is still a work in progress, some steps of this procedure could be useless, ugly and\/or dangerous<\/li>\n<li>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.<\/li>\n<li>GTK+ and all the packages underneath need a considerable amount of space and processor. If your embedded device provides a hard-drive\/compact-flash or a big flash and supports hardware accelerated graphics you can use GTK+ without problems.<\/li>\n<\/ol>\n<p><font size=\"4\"><br \/>\n<strong>Requirements<\/strong><br \/>\n<\/font><\/p>\n<p>Typically, when developing applications for an embedded system a cross-toolchain is needed. If you already have a cross-toolchain you don\u2019t have to worry about building it yourself. Otherwise, a well known resource for building one is <a href=\"http:\/\/www.kegel.com\/crosstool\" class=\"external\" rel=\"nofollow\">http:\/\/www.kegel.com\/crosstool<\/a><\/p>\n<p>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.<\/p>\n<p>The order in which the packages are compiled is important since some of them won\u2019t compile without the others. The packages, their versions and the order used for building GTK+ are the following:<\/p>\n<ul>\n<li>glib-2.15.4<\/li>\n<li>atk-1.23.5<\/li>\n<li>freetype-2.3.7<\/li>\n<li>zlib-1.2.3<\/li>\n<li>libxml2-2.6.30<\/li>\n<li>fontconfig-2.6.0<\/li>\n<li>libpng-1.2.29<\/li>\n<li>cairo-1.6.4<\/li>\n<li>pango-1.21.3<\/li>\n<li>gtk+-2.12.11<\/li>\n<\/ul>\n<p><font size=\"4\"><br \/>\n<strong>Environment configuration<\/strong><br \/>\n<\/font><\/p>\n<p>Suppose that the libraries will be installed in \/opt\/oe\/STM\/STLinux-2.2\/devkit\/sh4\/target\/usr\/local ( \/opt\/oe\/STM\/STLinux-2.2\/devkit\/sh4\/target is the root fs of the target) and that the cross-toolchain (compiler, linker\u2026) is in your path.<\/p>\n<p>Set the following environment variables that will make our life easier:<\/p>\n<pre lang=\"bash\">\n$ export PREFIX=\/opt\/oe\/STM\/STLinux-2.2\/devkit\/sh4\/target\/usr\/local\n$ export LD_LIBRARY_PATH=$PREFIX\/lib\n$ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH\/pkgconfig\n$ export COMPILER=sh4-linux-gcc\n$ export HOST=sh4-linux\n$ export BUILD=i386-linux<\/pre>\n<p><font size=\"4\"><br \/>\n<strong>Compiling the requirements<\/strong><br \/>\n<\/font><\/p>\n<p><font size=\"3\"><br \/>\n<em>Glib 2.15.4<\/em><br \/>\n<\/font><\/p>\n<p>Edit the &#8220;configure&#8221; file:<\/p>\n<p>Search for the texts &#8220;cannot run test program while cross compiling&#8221; and &#8220;cross-compiling&#8221;. Remove the following code that appe<br \/>\nars a couple of lines below the searched texts:<\/p>\n<pre lang=\"bash\">\n{ (exit 1); exit 1; };<\/pre>\n<p>Configure, compile and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX \n  --disable-largefile --disable-selinux --disable-gtk-doc --disable-man\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Atk 1.23.5<\/em><br \/>\n<\/font><\/p>\n<p>Configure, compile and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX --disable-glibtest --disable-gtk-doc\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Freetype 2.3.7<\/em><br \/>\n<\/font><br \/>\nConfigure, compilie and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Zlib 1.2.3<\/em><br \/>\n<\/font><br \/>\nConfigure, compilie and install:<\/p>\n<pre lang=\"bash\">\n$ CC=$COMPILER .\/configure --prefix=$PREFIX --shared\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>libxml2 2.6.30<\/em><br \/>\n<\/font><br \/>\nConfigure, compilie and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX --without-debug\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Fontconfig 2.6.0<\/em><br \/>\n<\/font><\/p>\n<p>Configure, compile and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX \n  --with-freetype-config=$PREFIX\/bin\/freetype-config --enable-libxml2 --with-arch=sh4  \n  --disable-docs\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>libpng 1.2.29<\/em><br \/>\n<\/font><\/p>\n<p>Edit the &#8220;configure&#8221; file:<\/p>\n<p>Set to &#8216;yes&#8217; the following variable:<\/p>\n<pre lang=\"bash\">\nac_cv_lib_z_zlibVersion=yes<\/pre>\n<p>Configure, compile and install:<\/p>\n<pre lang=\"bash\">\n$ .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Cairo 1.6.4<\/em><br \/>\n<\/font><\/p>\n<p>Configure, compile and install:<\/p>\n<pre lang=\"bash\">\n$ directfb_CFLAGS=\"-I$PREFIX\/..\/include\/directfb\" \n  directfb_LIBS=\"$PREFIX\/..\/lib\/libdirectfb.so \n  $PREFIX\/..\/lib\/libdirect.so \n  $PREFIX\/..\/lib\/libfusion.so\" \n  png_CFLAGS=\"-I$PREFIX\/include\" \n  png_LIBS=$PREFIX\/lib\/libpng12.so \n  FONTCONFIG_CFLAGS=\"-I$PREFIX\/include\/fontconfig\" \n  FONTCONFIG_LIBS=$PREFIX\/lib\/libfontconfig.so \n  FREETYPE_CFLAGS=\"-I$PREFIX\/include\/freetype2\" \n  FREETYPE_LIBS=$PREFIX\/lib\/libfreetype.so \n  .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX \n  --enable-directfb=yes --without-x --disable-xlib \n  --disable-xlib-xrender --disable-win32 --enable-pdf=no \n  --enable-ps=no --enable-png\n$ make\n$ make install<\/pre>\n<p><font size=\"3\"><br \/>\n<em>Pango 1.21.3<\/em><br \/>\n<\/font><\/p>\n<p>Set to &#8216;true&#8217; the following variables:<\/p>\n<pre lang=\"bash\">\nhave_cairo=true\nhave_cairo_png=true\nhave_cairo_freetype=true<\/pre>\n<p>Configure:<\/p>\n<pre lang=\"bash\">\n$ GLIB_CFLAGS=\"-I$PREFIX\/include\/glib-2.0 -I$PREFIX\/lib\/glib-2.0\/include\" \n  GLIB_LIBS=\"$PREFIX\/lib\/libglib-2.0.so \n  $PREFIX\/lib\/libgmodule-2.0.so \n  $PREFIX\/lib\/libgobject-2.0.so \n  $PREFIX\/lib\/libfontconfig.so \n  $PREFIX\/lib\/libxml2.so \n  $PREFIX\/lib\/libfreetype.so\" \n  CAIRO_CFLAGS=\"-I$PREFIX\/include\/cairo\" \n  CAIRO_LIBS=$PREFIX\/lib\/libcairo.so \n  FONTCONFIG_CFLAGS=\"-I$PREFIX\/include\" \n  FONTCONFIG_LIBS=$PREFIX\/lib\/libfontconfig.so \n  FREETYPE_CFLAGS=\"-I$PREFIX\/include\/freetype2\" \n  FREETYPE_LIBS=$PREFIX\/lib\/libfreetype.so \n  FREETYPE_CONFIG=$PREFIX\/bin\/freetype-config \n  .\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX --without-x<\/pre>\n<p>Edit Makefile:<\/p>\n<p>Delete from the SUBDIRS var the directory &#8216;examples&#8217;<\/p>\n<p>Edit tests\/Makefile:<\/p>\n<p>Add <em>GLIB_LIBS<\/em> to the <em>LIBS<\/em> variable:<\/p>\n<pre lang=\"bash\">\nLIBS = $(GLIB_LIBS)<\/pre>\n<p>Compile and install:<\/p>\n<pre lang=\"bash\">\n$ make\n$ make install<\/pre>\n<p><font size=\"4\"><br \/>\n<strong>Compiling GTK+ 2.12.11<\/strong><br \/>\n<\/font><\/p>\n<p>If DirectFB is in PREFIX\/..\/,<br \/>\nedit the files <em>directfb.pc<\/em>, <em>direct.pc<\/em> and <em>fusion.pc<\/em> in PREFIX\/..\/lib\/pkgconfig<\/p>\n<p>Set the prefix var to the following value:<\/p>\n<pre lang=\"bash\">\nprefix=\/opt\/oe\/STM\/STLinux-2.2\/devkit\/sh4\/target\/usr<\/pre>\n<p>Search for the texts &#8220;Can&#8217;t link to Pango&#8221;, &#8220;Can&#8217;t find cairo-ps.h&#8221; and &#8220;Can&#8217;t find cairo-pdf.h&#8221;.<br \/>\nRemove the following code that appears a couple of lines below the searched texts:<\/p>\n<pre lang=\"bash\">\n { (exit 1); exit 1; };<\/pre>\n<p>Configure:<\/p>\n<pre lang=\"bash\">\n$ BASE_DEPENDENCIES_CFLAGS=\"-I$PREFIX\/include \n  -I$PREFIX\/lib\/glib-2.0\/include -I$PREFIX\/include\/glib-2.0 \n  -I$PREFIX\/include\/pango-1.0 \n  -I$PREFIX\/include\/cairo \n  -I$PREFIX\/include\/atk-1.0\" \nBASE_DEPENDENCIES_LIBS=\"-L$PREFIX\/lib \n  $PREFIX\/lib\/libglib-2.0.so \n  $PREFIX\/lib\/libgobject-2.0.so $PREFIX\/lib\/libgmodule-2.0.so \n  $PREFIX\/lib\/libfontconfig.so $PREFIX\/lib\/libxml2.so\" \nGLIB_CFLAGS=\"-I$PREFIX\/include \n  -I$PREFIX\/lib\/glib-2.0\/include \n  -I$PREFIX\/include\/glib-2.0\" \nGLIB_LIBS=\"-L$PREFIX\/lib \n  $PREFIX\/lib\/libglib-2.0.so \n  $PREFIX\/lib\/libgobject-2.0.so \n  $PREFIX\/lib\/libgmodule-2.0.so \n  $PREFIX\/lib\/libfontconfig.so \n  $PREFIX\/lib\/libxml2.so\" \nPANGO_CFLAGS=\"-I$PREFIX\/include\/pango-1.0\" \nPANGO_LIBS=\"-L$PREFIX\/lib \n  $PREFIX\/lib\/libpango-1.0.so \n  $PREFIX\/lib\/libpangoft2-1.0.so \n  $PREFIX\/lib\/libpangocairo-1.0.so\" \nGDK_DEP_CFLAGS=\"-pthread -I$PREFIX\/include\/glib-2.0 \n  -I$PREFIX\/lib\/glib-2.0\/include \n  -I$PREFIX\/include\/pango-1.0 \n  -I$PREFIX\/include\/cairo \n  -I$PREFIX\/include \n  -D_REENTRANT -D_GNU_SOURCE \n  -I$PREFIX\/..\/include \n  -I$PREFIX\/..\/include\/directfb\" \nGDK_DEP_LIBS=\"-L$PREFIX\/lib -lpthread -ldl -lpangocairo-1.0 \n  -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lm \n  $PREFIX\/..\/lib\/libdirectfb.so \n  $PREFIX\/..\/lib\/libdirect.so \n  $PREFIX\/..\/lib\/libfusion.so\" \nGDK_PIXBUF_DEP_CFLAGS=\"-pthread -I$PREFIX\/include\/glib-2.0 \n  -I$PREFIX\/lib\/glib-2.0\/include \n  -I$PREFIX\/include \n  -I$PREFIX\/..\/include\" \nGDK_PIXBUF_DEP_LIBS=\"-L$PREFIX\/lib \n  -lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0 -lpng12 -lm\" \nGTK_DEP_CFLAGS=\"-pthread -I$PREFIX\/include\/glib-2.0 \n  -I$PREFIX\/lib\/glib-2.0\/include \n  -I$PREFIX\/include\/pango-1.0 \n  -I$PREFIX\/include\/cairo \n  -I$PREFIX\/include -D_REENTRANT -D_GNU_SOURCE \n  -I$PREFIX\/..\/include\/directfb \n  -I$PREFIX\/include\/atk-1.0 \n  -I$PREFIX\/..\/include\" \nGTK_DEP_LIBS=\"-L$PREFIX\/lib \n  -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 \n  -ldl -lglib-2.0 -lcairo -lpng12 -lm \n  $PREFIX\/..\/lib\/libdirectfb.so \n  $PREFIX\/..\/lib\/libdirect.so \n  $PREFIX\/..\/lib\/libfusion.so\" \nGDK_EXTRA_CFLAGS=\"-I$PREFIX\/..\/include\" \nGDK_EXTRA_LIBS=\"-L$PREFIX\/..\/lib -lz -lpthread -ldl \n  $PREFIX\/..\/lib\/libdirectfb.so \n  $PREFIX\/..\/lib\/libdirect.so \n  $PREFIX\/..\/lib\/libfusion.so\" \n.\/configure --host=$HOST --build=$BUILD --prefix=$PREFIX \n--with-gdktarget=directfb --without-libtiff --without-libjpeg \n--disable-glibtest --disable-largefile --disable-modules \n--with-included-loaders=gif,png,xpm<\/pre>\n<p>Edit gtk\/Makefile:<\/p>\n<p>Add to the <em>GTK_DEP_LIBS<\/em> var the following value:<\/p>\n<pre lang=\"bash\">\n -lfontconfig -lfreetype<\/pre>\n<p>Remove the linking line of the rule gtk-query-immodules-2.0$(EXEEXT).<br \/>\n<strong>Warning:<\/strong> This means that we won&#8217;t have this command available in the target.<\/p>\n<pre lang=\"bash\">\n#$(LINK)<\/pre>\n<p>Dangerous\/ugly step:<\/p>\n<p>GTK needs a cairo-pdf\/ps printing support for compiling,<br \/>\nbut it&#8217;s unlikely that PDF\/PS will be needed in an embedded system.<br \/>\nThere is no flag to compile it without this setting.<br \/>\nThere are some patches in development to solve this issue,<br \/>\nmeanwhile it was compiled without the cairo-pdf support by doing<br \/>\nthe following very ugly and dangerous step.<br \/>\nIf you want to add to add PDF\/PS support you can try Poppler.<\/p>\n<p>Edit the files:<\/p>\n<p>* gtk\/gtkprintoperation.c<br \/>\n* gtk\/gtkprintoperation-unix.c<br \/>\n* modules\/printbackends\/lpr\/gtkprintbackendlpr.c<br \/>\n* modules\/printbackends\/file\/gtkprintbackendfile.c<\/p>\n<p>Comment the lines in all these files that contains the following includes or function calls:<\/p>\n<pre lang=\"c\">\n#include <cairo-pdf.h>\n#include <cairo-ps.h>\ncairo_pdf_surface_set_size()\ncairo_pdf_surface_create()\ncairo_ps_surface_create_for_stream()\n<\/cairo-ps.h><\/cairo-pdf.h><\/pre>\n<p>Compile and install:<\/p>\n<pre lang=\"bash\">\n$ make\n$ make install<\/pre>\n<p>That&#8217;s it. Feel free to contact for any comment\/idea\/hint if you have any problem or want to improve this procedure.<\/p>\n<p><strong>Additional notes<\/strong><\/p>\n<p>If you want to include libjpeg you new to remove the option <em>&#8211;without-libjpeg<\/em> and add it to the option <em>&#8211;with-included-loaders=gif,png,xpm,jpeg<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. The first version of this guide used some unstable packages whilst this version uses only stable ones, but since I haven&#8217;t been\u00a0 to test it properly this\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=11\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7,10],"tags":[21,53,56],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-compiling","category-directfb","category-gtk","tag-cross-compile","tag-directfb","tag-gtk"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":0,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}