Skip to content

Best practices for building Gtk+ applications with OpenEmbedded

I recently wrote an article about best practices building Qt applications with OpenEmbedded, and it occured to me that I should write an equivalent article for Gtk+ applications.  The same points apply — put your application source in a SCM system, and put the install logic in the application source (read the above article).  The difference is that Gtk applications typically use autotools where Qt applications use qmake to build the application.  This article details how a minimal GTK+ application should be set up and built using OpenEmbedded.

Application Source

I created a sample GTK hello application located at: http://dev.bec-systems.com/svn/pub/gtk_hello.  This is a SVN repository, so you can simply “svn co” the above URI to check out the code.  If you are running Ubuntu, you can install the necessary tools to build a native Gtk+ application by:

  • sudo apt-get install libgtk2.0-dev build-essential autoconf automake pkg-config

To build on your x86 Linux PC, run the following steps:

This compiles and installs the application in to the “install” directory.  If you look in this directory, you will notice the application binary is installed in the “install/bin” directory.  Typically, the install directory is set to /usr/bin, but in this example we set it to install so we don’t need to run “make install” as root, but yet we can verify the install logic works properly.

OpenEmbedded Recipe

Now that you have verified the application builds and installs properly on a x86 PC, it is trivial to build the application in OpenEmbedded.  Create a recipe in your OE recipes directory named gtk-hello_svn.bb with the following contents:

DESCRIPTION = "Sample Gtk+ Hello application, used to demonstrate build system"
AUTHOR = "Cliff Brake <cbrake@bec-systems.com>"

SRCREV = "17"
PV = "0.0+svn${SRCREV}"
PR = "r0"

DEPENDS = "gtk+"

SRC_URI = "svn://dev.bec-systems.com/svn/pub;module=gtk_hello;proto=http;rev=17"

S = "${WORKDIR}/gtk_hello/"

inherit autotools

Now, run: bitbake gtk-hello.  That is it!  Building Linux applications is easy if you simply use the tools, whether it be autotools, qmake, etc.  Too often there is the tendency to set up your own compile steps with ${CC} variables, etc.  While this seems to be the simple approach at first glance (autotools is too hard), it quickly becomes unmaintainable and in the end is a lot more work than simply learning the basics of the industry standard tools.  See previous autotools article for more information.

6 thoughts on “Best practices for building Gtk+ applications with OpenEmbedded”

  1. I copy it to another project and use as local (not use svn)

    my bb file

    PR = “r0”

    DEPENDS = “gtk+”

    SRC_URI = “file://hello.c \
    file://configure.ac \
    file://Makefile.am”

    S = “${WORKDIR}/helloapp/”

    inherit autotools

    files in my dir look like this
    files/ contains configure.ac, Makefile.am and hello.c
    helloapp/ copied from files/ and run autotools on first step
    moss-hello_1.0.0.bb
    when bitbake it show this error
    —-
    | NOTE: make DESTDIR=/~~/overo-oe/tmp/work/armv7~~/moss-hello-1.0.0-r0/image install
    | make: *** No rule to make target `install’. Stop.
    | FATAL: oe_runmake failed
    —-
    How can i fix it? Thank.

  2. in the above example, I think you need to change S to:
    S=”${WORKDIR}”

    The helloapp directory is created by the SVN checkout. Since we are not doing that step, we need to adjust S.

  3. Oh sorry. I found problem again.
    I copy package gtk-hello~*.ipk from tmp/deploy/glibc/ipk/armv7a/ to my microSD that install omap3-desktop-image.
    Than boot and try to install it , and it say:
    Cannot satisfy the following dependencies
    gtk+ (>= 2.18.0) , libgio-2.0-0 (>=2.22.0), libgobject-2.0-0 (>=2.22.0) , libgmodule-2.0-0 (>=2.22.0) , libglib-2.0-0 (>=2.22.0)

    but some package on this list is not in the package (bb) that provide by overo-oe.

Comments are closed.