Fixing a Snapcraft Build that had been Broken for Two Years
As I stated in my introduction , the first piece of work I did on Packet Sender was fix the Snapcraft build. What is Snapcraft? It has been a while since I've worked with Ubuntu, so I wasn't up to speed with how Ubuntu was now doing things like package management. As I understand it, apt and/or apt-get is still a thing, but Snapcraft is the new shiny. Snapcraft is more than just an app…
Two years ago, I embarked on a project to repair a broken Snapcraft build for Packet Sender. Snapcraft is an all-in-one build system, dependency manager, and packager. While it simplifies the process, it can also present challenges. When attempting to run Packet Sender, it would crash with an error message indicating that the shared library libpxbackend-1.0.so could not be found.
As someone who grew up in the Microsoft era, I was already familiar with .dll files, which serve a similar purpose to shared libraries in *nix systems. However, Microsoft's implementation was flawed, leading to the development of shared libraries in Unix-like systems. The error message pointed to the fact that the library was expected to be in a specific location, but it was not.
Initially, I tried hardcoding paths or modifying the Qt library version, but these attempts were unsuccessful. Then, I utilized Grok, a tool that guided me towards the libproxy1v5 library and the addition of an LD_LIBRARY_PATH environment variable. Regrettably, this solution did not resolve the issue.
A breakthrough came when Dan Nagle suggested using the kde-neon-6 Snapcraft plugin. This extension provides a fully configured Qt 6 stack, which correctly stages shared libraries, including the missing libpxbackend-1.0.so. Consequently, I could eliminate many stage-packages and build-packages, and convert the build system to CMake, a more modern and preferred build system in KDE.
The executable size shrank dramatically, from 165MB to just under 6MB, due to the bundled Qt 6 libraries. Additionally, the build process was expanded to support both amd64 and arm64 architectures, enabling Packet Sender to run on Raspberry Pi hardware.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.