Building an executable with Nix that can run on Ubuntu 16.04

Hi! First post here, after doing a ton of work the last 3 weeks moving our software build system to rely on Nix. One of the scenarios that I need to support is building a Qt5 app with the goal of producing an AppImage that’ll run on Ubuntu 16.04 and later. While the produced AppImage already runs on Ubuntu 18.04 (which has glibc 2.27), there’s a problem running on 16.04 because it only has glibc 2.23, so I get this error:

relocation error: AppDir/usr/bin/../lib/ symbol _dl_exception_create, version GLIBC_PRIVATE not defined in file with link time reference

Is this something that is supported? E.g. is it possible to change the glibc package being used in my derivation to 2.23?

UPDATE: This is the actual error from the CI build job:

15:41:45  /home/jenkins/workspace/status-react_prs_linux_PR-7506/linuxdeployqt-continuous-x86_64_20181215.AppImage: relocation error: /nix/store/0fv2lnbr02qzh3l387rvd6vl8443mpq7-glibc-2.27/lib/ symbol _dl_exception_create, version GLIBC_PRIVATE not defined in file with link time reference

I think you can use the glibc from the Nix store on any Linux kernel. Do you know where /usr/lib/ is coming from? Likewise the value of LD_LIBRARY_PATH.

Added more detail from the CI build job in the OP. LD_LIBRARY_PATH was empty. I will try copying the glibc from the Nix store to the AppDir folder on 16.04, along with any missing dependencies reported by ldd through the dependency tree and see if that might work.

The safest thing to do would be to copy all the paths in
nix-store --query --requisites /nix/store/the-path-you-are-interested-in to the chroot of the AppImage instead of picking libraries by hand.

1 Like

Thanks for the tip, I’ll take a look. In any case, I’m not picking them by hand, I wrote a script which uses ldd to follow the exact dependencies and copy/patch them.

By the way, I was able to get an AppImage that runs on Ubuntu 16.04, at the expense of a large distributable!

nix-bundle actually has an appimage script that does this for you:

1 Like

I’ve used the above mentioned nix-bundle for a similar use-case and other than a large bundle, it works perfectly. Never had a dependency issue.