Architecture help (Old GTK2 App to become a Snap)

This is a Sega Genesis/Mega Drive emulator named “Kega Fusion” I am trying to package as a snapcraft package, however I do not know how to make it into a 32-bit app. It builds thankfully, but I do not know how to force it to compile into 32-bit, meaning whilst testing, it will not open, resulting this error message.

/snap/kega-fusion/x1/Fusion: error while loading shared libraries: libGL.so.1: wrong ELF class: ELFCLASS64

This is my snapcraft.yaml.

name: kega-fusion
title: Kega Fusion
version: 3.63-2
summary: Sega Genesis/Mega Drive Emulator
description: |
  Kega Fusion is an emulator for the Sega Genesis/Sega Mega Drive line up of home consoles with support for the Sega CD, 32X and more. Kega Fusion also features extremely accurate emulation and VGM ripping, with Plugin and shader support, and online functionality developed by Steve Snake.
icon: snap/gui/kega-fusion.png
confinement: strict
base: core18

architectures:
  - build-on: i386
    run-on: [amd64, i386]

apps:
  kega-fusion:
    command: desktop-launch $SNAP/Fusion
    environment:
      # This is a GTK2 app, it's about as old as I am lol.
      DISABLE_WAYLAND: 1
    plugs:
      - x11
      - unity7
      - home
      - network
parts:
  i386:
    plugin: nil
    override-build: |
      sudo dpkg --add-architecture i386
      sudo apt-get update
  kega-fusion:
    plugin: dump
    source: https://www.carpeludum.com/download/Fusion363x.tar.gz
    stage-packages:
      - libglu1-mesa
      - libsm6
      - libasound2
      - libasound2-plugins
      - libmpg123-0
      - gtk2-engines-murrine
      - gtk2-engines-pixbuf
    after: 
      - desktop-gtk2
      
  # This part installs the `desktop-launch` script which initialises desktop
  # features such as fonts, themes and the XDG environment. It also installs
  # the GTK2 runtime libraries.
  #
  # It is copied straight from the snapcraft desktop helpers project. Please
  # periodically check the source for updates and copy the changes.
  #    https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml
  #
  desktop-gtk2:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
      - build-essential
      - libgtk2.0-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
      - libgtk2.0-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk2.0-bin
      - unity-gtk2-module
      - locales-all
      - libappindicator1
      - xdg-user-dirs
      - ibus-gtk
      - libibus-1.0-5

plugs:
  gtk-2-engines:
    interface: content
    target: $SNAP/lib/gtk-2.0
    default-provider: gtk2-common-themes
  gtk-2-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

Hello I’m the second person that tried to package this old app as a snap.

name: kega-fusion
title: Kega Fusion
grade: stable
version: 3.63-2
summary: Sega Genesis/Mega Drive Emulator
description: |
  Kega Fusion is an emulator for the Sega Genesis/Sega Mega Drive line up of home consoles with support for the Sega CD, 32X and more. Kega Fusion also features extremely accurate emulation and VGM ripping, with Plugin and shader support, and online functionality developed by Steve Snake.
confinement: strict
base: core20

architectures:
 - build-on: amd64
   run-on:   amd64

layout:
  /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
    bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
  /usr/share/alsa:
    bind: $SNAP/usr/share/alsa
  /etc/alsa:
    bind: $SNAP/etc/alsa
  /usr/lib/libmpg123.so.0:
    symlink: $SNAP/usr/lib/i386-linux-gnu/libmpg123.so.0

apps:
  kega-fusion:
    command: bin/desktop-launch $SNAP/kega-snap-launch
    environment:
      # This is a GTK2 app, it's about as old as I am lol.
      DISABLE_WAYLAND: "1"
      LD_LIBRARY_PATH: "$SNAP/usr/lib/i386-linux-gnu:$SNAP/lib/i386-linux-gnu"
    plugs:
      - x11
      - unity7
      - home
      - network
      - opengl
      - audio-playback
      - pulseaudio
      - desktop
      - desktop-legacy
      - alsa


parts:
  i386:
    plugin: nil
    override-build: |
      sudo dpkg --add-architecture i386
      sudo apt-get update


  kega-fusion:
    plugin: dump
    source: https://www.carpeludum.com/download/Fusion363x.tar.gz
    stage-packages:

      - libasound2:i386
      - libmpg123-0:i386
      - gtk2-engines-murrine:i386
      - gtk2-engines-pixbuf:i386
      - libsm6:i386
      - libatk1.0-0:i386
      - libcairo2:i386
      - libgdk-pixbuf2.0-0:i386
      - libglib2.0-0:i386
      - libgtk2.0-0:i386
      - libpango-1.0-0:i386
      - libpulse0:i386
      - libxau6:i386
      - libxcb1:i386
      - libxdmcp6:i386
      # kega needs these in my PC (down)
      - libasound2-plugins:i386
      - libpulsedsp:i386
      - libuuid1:i386
      - libatk-adaptor:i386
      - libgail-common:i386
      #- pipewire-alsa:i386
    override-build: |
      snapcraftctl build
      rm -rf $SNAPCRAFT_PART_INSTALL/lib/x86_64-linux-gnu
      rm -rf $SNAPCRAFT_PART_INSTALL/usr/lib/x86_64-linux-gnu
      rm -fr $SNAPCRAFT_PART_INSTALL/lib/bindtextdomain.so

    after:
      - desktop-gtk2
      - i386

  kega-launch:
    plugin: nil
    source-type: local
    source: misc
    override-build: |
      install -Dm755 kega-snap-launch.sh $SNAPCRAFT_PART_INSTALL/kega-snap-launch
      cp Fusion.ini $SNAPCRAFT_PART_INSTALL/Fusion.ini
    stage-packages:
      - libglu1-mesa:i386
      - libgl1-mesa-dri:i386
      - libgl1:i386
      - libglapi-mesa:i386
      - libglx-mesa0:i386
      - libglx0:i386
      - libfontconfig1
      - libfreetype6
      - libgdk-pixbuf2.0-0
      - libicu66
      - libpng16-16
      - libxml2



  # This part installs the `desktop-launch` script which initialises desktop
  # features such as fonts, themes and the XDG environment. It also installs
  # the GTK2 runtime libraries.
  #
  # It is copied straight from the snapcraft desktop helpers project. Please
  # periodically check the source for updates and copy the changes.
  #    https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml
  #
  desktop-gtk2:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
      - build-essential
      - libgtk2.0-dev
    stage-packages:
      - libxkbcommon0:i386  # XKB_CONFIG_ROOT
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libglib2.0-bin:i386
      - libgtk2.0-bin:i386
      - unity-gtk2-module
      - locales-all
      - xdg-user-dirs
      - ibus-gtk:i386
      - libibus-1.0-5:i386


plugs:
  gtk-2-engines:
    interface: content
    target: $SNAP/lib/gtk-2.0
    default-provider: gtk2-common-themes
  gtk-2-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

kega-snap-launch.sh

#!/bin/sh

#kega_libdir="/usr/lib/kega-fusion"
#kega_sharedir="/usr/share/kega-fusion"
kega_localdir="$HOME/.Kega Fusion"

mkdir -p "$kega_localdir"

# create local plugins directory if not present
# mkdir -p "$kega_localdir/Plugins"

# create links for every included plugin
#if [ $(ls -1A $kega_libdir/plugins | wc -l) -gt 0 ]; then
#  for i in $kega_libdir/plugins/*; do
#    ln -sf "$i" "$kega_localdir/Plugins/$(basename "$i")"
#  done
#fi

# copy configuration file if not present
if ! [ -f "$kega_localdir/Fusion.ini" ]; then
  cp $SNAP/Fusion.ini "$kega_localdir"/Fusion.ini
fi

# here we go!
$SNAP/Fusion "$@"


Fusion.ini

ALSADeviceName=plughw
OSSDeviceName=/dev/dsp
UsingALSA=1
libmpg123path=/usr/lib/libmpg123.so.0
CurrentWaveFormat=2
SoundOverdrive=0
SoundDisabled=0
AlternateTiming=3
AllowSleeping=1

I managed to pop the gui up and it works kinda fine on devmode but in strict mode it just shows a black screen. Well a step forward i guess. :man_shrugging: