Building a snap

So currently I’m attempting to craft a snap for my project visualboyadvance-m

making use of wxwidgets gtk3 sdk stage snap, but in our code we also make use of polling gtk directly regarding wayland support so we include in our cmake the requirement for libgtk-3-dev.

trying to build what I have, cmake doesn’t seem to quite find gtk and I was wondering if someone could point me in the right direction.

name: visualboyadvance-m
version: 2.1.4
summary: Nintendo Game Boy Advance Emulator
description: |
  An open-source Nintendo Game Boy, Super Game Boy, Game Boy Advance Emulators.

confinement: strict
base: core18

plugs:

  desktop:
  desktop-legacy:

  home:
  removable-media:

  network:

parts:
  wxwidgets-sdk:
    plugin: nil
    stage-snaps:
    - wxwidgets-sdk-gtk3
    stage-packages:
    # Crash dialog support
    - binutils
    filesets:
      crash-dialog-support:
      - usr/bin/*addr2line
      library-shared:
      - '**/lib/**/*.so*'
    prime:
    - $crash-dialog-support
    - $library-shared
  vbam:
    after:
    - wxwidgets-sdk

    source: https://github.com/visualboyadvance-m/visualboyadvance-m/archive/v2.1.4.tar.gz
    plugin: cmake
    build-packages:
      - g++
      - gcc
      - make
      - cmake
      - pkg-config
      - git
      - libsdl2-dev
      - libsfml-dev
      - libgtk-3-dev
      - libopenal-dev
    configflags:
      - -DENABLE_OPENAL=ON
      - -DENABLE_SDL=OFF

apps:
  visualboyadvance-m:
    command: bin/visualboyadvance-m

I know there’s a lot more I need to get before it’s complete, but for now I just want to at least the building stage started.

Bump, it’s been 12 days now and I’m still no where near any clue of what I’m doing wrong.

if you could put a complete build log with the failure on https://paste.ubuntu.com/ and link it here, potential helpers would have some more thing to look at :wink:

guessing the error by staring your snapcraft.yaml isnt really possible …

Well personally I’d rather use hastebin :wink: As for the error, that will have to wait. Seems I’m having a snapd issue currently and snapcraft is throwing me

cannot change profile for the next exec call: No such file or directory

https://hasteb.in/wafayilu.lua

Seems even though I have gtk3 devel included into the yaml file, it isn’t picking up the fact it’s installed

Just a small ping, I’m still having no luck at this other than rewriting perfectly a good feature check at the source level for gtk3 wayland support.

It appears that https://hasteb.in/wafayilu.lua just redirects to https://hasteb.in - i don’t see the error you tried to link to. Can you please try again or maybe use paste.ubuntu.com or even just post it here?

1 Like

Probably won’t help much, but I added a desktop-gtk3 part and an after statement to vbam. This used to be necessary, but I’m not sure now:

name: visualboyadvance-m
version: 2.1.4
summary: Nintendo Game Boy Advance Emulator
description: |
  An open-source Nintendo Game Boy, Super Game Boy, Game Boy Advance Emulators.

confinement: strict
base: core18

plugs:

  desktop:
  desktop-legacy:

  home:
  removable-media:

  network:

parts:
  wxwidgets-sdk:
    plugin: nil
    stage-snaps:
    - wxwidgets-sdk-gtk3
    stage-packages:
    # Crash dialog support
    - binutils
    filesets:
      crash-dialog-support:
      - usr/bin/*addr2line
      library-shared:
      - '**/lib/**/*.so*'
    prime:
    - $crash-dialog-support
    - $library-shared
 vbam:
    after:
    - wxwidgets-sdk

    source: https://github.com/visualboyadvance-m/visualboyadvance-m/archive/v2.1.4.tar.gz
    plugin: cmake
    build-packages:
      - g++
      - gcc
      - make
      - cmake
      - pkg-config
      - git
      - libsdl2-dev
      - libsfml-dev
      - libgtk-3-dev
      - libopenal-dev
    configflags:
      - -DENABLE_OPENAL=ON
      - -DENABLE_SDL=OFF
    after:
      - desktop-gtk3


  desktop-gtk3:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk3"]
    build-packages:
      - build-essential
      - libgtk-3-dev
    stage-packages:
      - libxkbcommon0  # XKB_CONFIG_ROOT
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgtk-3-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk-3-bin
      - unity-gtk3-module
      - libappindicator3-1
      - locales-all
      - xdg-user-dirs
      - ibus-gtk3
      - libibus-1.0-5

apps:
  visualboyadvance-m:
    command: bin/visualboyadvance-m

But the error is still (I’m assuming this is more-or-less the error you see):

CMake Error at src/wx/CMakeLists.txt:449 (message):
  Could not find gtk
  

-- Configuring incomplete, errors occurred!
See also "/root/parts/vbam/build/CMakeFiles/CMakeOutput.log".
See also "/root/parts/vbam/build/CMakeFiles/CMakeError.log".
Failed to run 'cmake /root/parts/vbam/src -DCMAKE_INSTALL_PREFIX= -DENABLE_OPENAL=ON     -DENABLE_SDL=OFF' for 'vbam': Exited with code 1.
Verify that the part is using the correct parameters and try again.

Total guess here, but I think the gtk check is not looking in the right place for a snap build. One way to debug this is to log into the lxd container (use snapcraft --use-lxd to use LXD instead of multipass, or you can log into the multipass VM. Same difference, but I find lxd easier to work with) and poke around in the stage directories to see where gtk lives during snap build. The LXD is a kind of beta feature, but I use it all the time.

lxc start snapcraft-visualboyadvance-m
lxc exec snapcraft-visualboyadvance-m bash
# cd /root
# ls stage

As I said, this probably won’t help much, but maybe it’ll help you figure out a good debugging path forward, which is usually: my build can’t find X. Search for where snapcraft puts it in the build container, modify snapcraft.yaml, try again.

Good luck.

isnt wxwidgets C++ ?

if thats true, libgtk-3-dev in build packages will surely not help, you want the gtkmm equivalent instead …

@hellsworth crap, forgot hastebin recently changed how it retains content.

@jsseidel pretty much the fact it can’t find gtk, and while I like the idea of snaps, stuff like this makes it kinda frustrating. My platform however doesn’t use LXD, so I’ll have to try and debug with multipass.

For ogra, it is, but we take direct use of gtk3 specific functions mainly GDK to detect we are using wayland or not https://github.com/visualboyadvance-m/visualboyadvance-m/blob/master/src/wx/wayland.cpp

Your cmake build tries to compile and run a test to determine if the available wxwidgets is usable. This fails to find the wxwidgets setup.h header and then falls through to the cannot find GTK message due to all the subsequent checks failing for the same reason. To make the build able to find the wxwidgets setup.h header you need to add CFLAGS and CXXFLAGS environment variables to your part in snapcraft.yaml:

parts:
  ...
  vbam:
    ...
    build-environment:
      - CFLAGS: -I$SNAPCRAFT_STAGE/lib/wx/include/gtk3-unicode-3.0
      - CXXFLAGS: -I$SNAPCRAFT_STAGE/lib/wx/include/gtk3-unicode-3.0
    ...

You also need to add a build-package for zip and libnotify-dev or the build will fail further along… You’ll likely want to also add libnotify4 as a stage package or reference it with the gnome-3-28 extension.

@daniel That’s exactly what I needed, much appreciation.

So I managed to get things going, everything built, and then got my runtime bundled, however

I think I need to dig around with audio stuff. But I do have things working to the point where things load (opengl though is something that’s not exactly working)

But I did manage to get the entirety of the snap built

https://gist.github.com/ZachBacon/b4c76c3111c5dcb3c166c27ed1912aec

if anyone has suggestions for opengl support I’m all ears, as for the audio, I think I know what I’m missing, just gonna go through the documentation.
[edit]

Got it, was missing the audio-playback plug

[edit2]

Got my opengl issue finally resolved, missed the opengl plug and needed to add

  - libgl1
  - libglvnd0
  - libglx0
  - libopengl0

And things are working, just need to fix icon location and I can begin rollout of a test release.

Much thanks for those that lent a hand in helping with this.
snapcraft