John Woltman's
Festival of Conviviality

Nerd Stuff

Cross-compile Qt for a Raspberry Pi with Ansible (CentOS)

Posted March 15, 2017 by John Woltman

Have you ever wanted to cross-compile a Qt application on your Raspberry Pi but hate bash scripts because bash scripts are literal garbage?  Well now you can, with some handy Ansible playbooks that I wrote!

Simplify Complex Processes

Ansible is a tool used to automate computer configuration, usually on Linux servers.  It lets an administrator run a sequence of tasks and makes sure the tasks get applied to a fleet of computers.  However, it is also great for configuring just a few computers that may need some complicated configuration.  If I think I might have to do a task more than once, I use Ansible instead of manually typing commands into a shell.

A good example of complicated configuration is setting up a cross-compilation toolchain on your Linux desktop so that you can build Qt apps for your Raspberry Pi.  I submit to you this excellent wiki article on setting up Qt for the Raspberry Pi as an example of a complicated process.  This article was indispensable to me and helped me get Qt running on my Pi2.

However, I never want to go through the manual process again, so I wrote some Ansible playbooks to help me automate it.  The advantage is if I have to upgrade to a future version of Qt, say 5.9.1, I'll be able to do so easily and deploy the new version to my Pi exactly like I did version 5.9.0.

My Ansible Solution

I've posted my Ansible playbooks on Bitbucket so download them there.  I assume you have a working Ansible installation, and that you're using CentOS 7 (a good Linux).  The README provided on Bitbucket will give further instructions, but here's a brief overview of the three playbooks:

  • 01 - Set up the Raspberry Pi with development tools that will be needed for the next playbook.
  • 02 - Set up the CentOS 7 host with a cross-compilation toolchain and compile Qt 5.9 for the Raspberry Pi.
  • 03 - Deploy Qt (and your own software) to the Raspberry Pi.  You can run this again whenever you update Qt or build new versions of your software.  A little Ansible knowledge will help.

 

blog comments powered by Disqus