2 ms·
It isn't nearly as trivial as you imply. First you have to track down every shared lib and every shared lib that lib depends on, then you have to create a launc
by AnIdiotOnTheNet 5y ago
It isn't nearly as trivial as you imply. First you have to track down every shared lib and every shared lib that lib depends on, then you have to create a launcher script that specifies LD_LIBRARY_PATH and possibly also launches with a particular ld.so to ensure compatibility. If the application dynamically loads any libraries via API instead of the ELF you might need something like seccomp to intercept and rewrite paths in syscalls or screw around with user namepsacing. And that's just the tip of the iceberg when it comes to portablizing Linux applications.
- charcircuit 5y agoAnd it's not as simple as just statically compiling all your dependencies into the final executable either.
- ninkendo 5y agoYou can link with the -rpath flag to hardcode an RPATH into the executable, which is essentially an LD_LIBRARY_PATH specified by the executable itself. It can be a relative path too, if you want to put the binary and its required .so’s in the same prefix. But yeah, this isn’t common to do in the Linux world, unfortunately, because it’s expected that binaries and libraries live in distinct places on the filesystem, rather than bundling them together into an app bundle like on macOS.
- AnIdiotOnTheNet 5y agoYeah, and thanks to Nix you can use PatchELF[0] to change the rpath on a binary too. Point being that for users it is not a straight-forward process to make a Linux application portable. Thanks to Linux Desktop's lackadaisical approach to userspace ABI compatibility it isn't necessarily that easy for developers either. [0] https://github.com/NixOS/patchelf https://github.com/NixOS/patchelf