Ubuntu – Use GTK3 in a snapcraft app


How can I use Gtk3 in my snap app? should I add Gtk3 as a plugin to snapcraft.yaml? and how to build it?
However I can build Gtk3 outside of snapcraft system.

Best Answer

  • Take a look at https://github.com/ubuntu/snappy-playpen/blob/master/galculator/snapcraft.yaml - it's actually quite straight-forward:

    The relevant bit is parts: galculator: source: https://github.com/galculator/galculator.git plugin: autotools install-via: prefix build-packages: - flex - gettext - intltool - libgtk-3-dev - libpng12-dev - libxml-parser-perl stage-packages: - libglib2.0-0 - libgtk-3-0 - libpango-1.0-0 - libpng12-0 - libquadmath0 - dconf-gsettings-backend - librsvg2-common - libwmf0.2-7-gtk - libgdk-pixbuf2.0-0 after: [gtkconf]

    A few points: - it uses the autotools plugin to build the package - it pulls in libgtk3-dev (and other packages) as build-packages, so packages you need to have locally installed to build the snap - it mentions dependencies as stage-packages which are then bundled with the snap - it uses the gtkconf wiki part for the launcher

    Have a look at the full example though, it should help getting your GTK3 app to build.