We're hiring!
*

Cross-compilation made easy for GNOME Builder

Corentin Noël avatar

Corentin Noël
August 03, 2018

Share this post:

GNOME Builder is an Integrated Development Environment designed for the GNOME ecosystem. It most notably features a deep integration to the Git version control system, allow to debug applications quickly using the GNU Debugger and allow in-line documentation viewing using Gtk-Doc.

By being very powerful and versatile, GNOME Builder is starting to take a prominent place in the IDE world. But many developers building GNOME applications for an embedded platform need an IDE that handles the very specific requirements of embedded systems development.

Developing applications for embedded devices has always required lots of extra work or required some platform-specific tools that do not fit the assumptions made by GNOME Builder.

GNOME Builder Website

To fulfill the specific needs of the embedded devices, I had to split my work in two steps: allow to specify a sysroot (added with a plugin in GNOME Builder) and adding the support of the cross-compilers (which required some internal changes).

Specify the system root

Developing for a different device than the one you are currently using often mean that you will use a libraries with different version than your system, or that you'll even use different libraries that are not necessary available on your system.

For this very specific reasons, developer are often provided a copy of the system root directory of the targeted device.

By default, any build system, being Autotools, CMake or Meson, try to provide the dependencies from the standard directory of your system. There is an option in most compiler named --sysroot that, when used, allow the components to be found relatively to this different system root directory.

As most modern libraries make use of pkg-config to declare their dependencies and build flags, it is also important to ensure that this tool respects the given root directory.

To automate these tasks in GNOME Builder, a new module has been created named "Sysroot". It allows you to define very quickly your targeted system following a few simple steps.

Screenshot: sysroot

Once created, the sysroot will then be available in the Runtime section of your project configuration. You'll be able to build your application using the sysroot by just clicking on the build button.

Cross-compilation

We are now able to compile a software using different libraries than the one provided by the system. But this change targets a really limited scope as it is only really working when compiling for the very same architecture.

Let's now imagine that the build machine (the one compiling the application) has a different architecture from the host machine (the one running the generated application). We then need to use a cross-compiler to properly generate the binaries for a specific architecture.

Most if not all modern GNU/Linux distribution has packages to install the cross-compiler targeting a large set of architectures, and very specific architectures often comes with a cross-compiler made by the vendor.

The development version 3.29.2 of GNOME Builder introduced the concept of Toolchain: as a set of tools used to compile a software and is expected to be available in the stable version 3.30 to be released in a few months.

GNOME Builder has embedded support of toolchain autodetection; detecting the cross-compiler installed in the standard locations in your system, parsing the cross-compilation files for Meson in well-defined system and user directories, and also in the project directory for Meson and CMake. A defined sysroot leading to a Yocto root directory should also be able to provide the toolchain installed with the SDK aside.

And as GNOME Builder already has support of running applications using QEMU, It is now possible to build and run a cross-compiled GTK+ application directly from the GUI.

Test it in a few steps

A virtual machine image is available here (3.6 GB).

The virtual image above already contains everything you need to test. If you prefer to make the image yourself, here are a few steps to reproduce it:

  1. Grab your favorite embedded device (I'm using an ODROID XU3)
  2. Download and install GNOME Builder nightly builds (flatpak install https://gitlab.gnome.org/GNOME/gnome-apps-nightly/raw/master/gnome-builder.flatpakref) Install a cross-compiler using your favorite package manager (for instance sudo apt install gcc-arm-linux-gnueabihf)
  3. Copy the root of the filesystem of your embedded device in your computer (I'm using the images provided at odroid.in and extracted everything in ~/sysroot)
  4. Start GNOME Builder and open PreferencesSDKs and add a new sysroot by clicking on the + button in the Sysroots section, fill the popover according to your configuration.
  5. On GNOME Builder welcome screen click on the clone… button and clone the sample project https://gitlab.collabora.com/tintou/gnome-builder-sample-app.git

    Screenshot: sysroot

  6. The project comes with some example cross-toolchain files (aarch64-poky-linux.crossgen) for instance that you'll need to adapt to your configuration.
  7. Click on the omnibar in the headerbar and click on the Configure build preferences button then select the default profile on the left column, then your previously configured Sysroot and Toolchain (the sysroot is under the runtime section). When you change the sysroot, be careful to also use the corresponding toolchain.
  8. Click on the omnibar in the headerbar and click clean then build. You can click on the run button to test the application.

Thanks

Shoutouts to Christian Hergert for his very effective reviews and his time spend on merging these changes to GNOME Builder.

Big thanks to Guillaume Tucker for mentoring me during this internship and to Gustavo Noronha for initiating the task on Collabora's R&D department.

Comments (0)


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Search the newsroom

Latest Blog Posts

An easy to use MTP implementation for your next embedded Linux project

13/04/2021

Did you know you could run a permissively-licensed MTP implementation with minimal dependencies on an embedded device? Here's a step-by-step…

Rust: integrating LLVM source-base code coverage with GitLab

24/03/2021

Earlier this year, the Rust compiler gained support for LLVM source-base code coverage. In this post we'll explain how to setup a CI job…

Build and run GTK 4 applications with Visual Studio

18/03/2021

Over the past few months, I've been working on a side project to improve Meson sub-project support. The best stress test is to build projects…

New features, changes & improvements to KernelCI's UI

04/03/2021

The most complete automated testing and continuous integration tool for the Linux kernel continues to evolve at a rapid pace. Here's a look…

Asymmetric Multi Processing with Linux & Zephyr on the STM32MP1

03/03/2021

In the embedded world, many modern SoCs such as the ST Microelectronics STM32MP1 now include coprocessor cores which can be used for a wide…

Adding HEVC/H.265 support for NXP's i.MX 8M

17/02/2021

Our recent efforts on the Hantro kernel driver have resulted in the addition of H.264 decoding support and multiple performance improvements.…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2021. All rights reserved. Privacy Notice. Sitemap.

Collabora Limited is registered in England and Wales. Company Registration number: 5513718. Registered office: The Platinum Building, St John's Innovation Park, Cambridge, CB4 0DS, United Kingdom. VAT number: 874 1630 19.