AppImageCommunity / pkg2appimage

Tool and recipes to convert existing deb packages to AppImage
http://appimage.org
MIT License
698 stars 216 forks source link

Use rpath=$ORIGIN instead of LD_LIBRARY_PATH #89

Open probonopd opened 8 years ago

probonopd commented 8 years ago

Should avoid issues with apps that are loaded outside of the AppImage by something inside the AppImage, and is much cleaner.

It can be changed in already-compiled binaries and libraries using http://nixos.org/patchelf.html.

https://github.com/probonopd/linuxdeployqt makes use of this.

probonopd commented 8 years ago
       ld.so understands certain strings in an rpath specification (DT_RPATH
       or DT_RUNPATH); those strings are substituted as follows

       $ORIGIN (or equivalently ${ORIGIN})
              This expands to the directory containing the program or shared
              object.  Thus, an application located in somedir/app could be
              compiled with

                  gcc -Wl,-rpath,'$ORIGIN/../lib'

              so that it finds an associated shared object in somedir/lib no
              matter where somedir is located in the directory hierarchy.
              This facilitates the creation of "turn-key" applications that
              do not need to be installed into special directories, but can
              instead be unpacked into any directory and still find their
              own shared objects.

       $LIB (or equivalently ${LIB})
              This expands to lib or lib64 depending on the architecture
              (e.g., on x86-64, it expands to lib64 and on x86-32, it
              expands to lib).

       $PLATFORM (or equivalently ${PLATFORM})
              This expands to a string corresponding to the processor type
              of the host system (e.g., "x86_64").  On some architectures,
              the Linux kernel doesn't provide a platform string to the
              dynamic linker.  The value of this string is taken from the
              AT_PLATFORM value in the auxiliary vector (see getauxval(3)).
zot commented 5 years ago

Nice! I didn't know ld.so expanded any variables at all.

Talk about bells and whistles...