1. 8

  2. 8

    I am not sure why this piece of trivial and awful advice was posted here, but for further reference, if you are an ISV, and not an operating system distribution that controls all packaging, set RPATH in your binaries. Do not set LD_LIBRARY_PATH when running programs. I must repeat this in caps, because it’s too important, and many are doing it wrong:


    Use -L to find libraries at link time, and use -R to tell the dynamic linker to find shared libraries at run time. Also, learn about $ORIGIN to make relocatable packages.

    LD_LIBRARY_PATH is a debug option. Do not set LD_LIBRARY_PATH under normal circumstances! Build your software correctly in the first place!

    1. 4

      A slight nitpick, but identifiers starting with an underscore and a capital letter are reserved (C11 7.1.3). The include guard should use something like MYLIB_H_INCLUDED instead of _MYLIB_H_

      1. 0

        Don’t do that. Use autotools and libtool to get a more manageable library: https://autotools.io/libtool/index.html

        You’ll work less in the long run and be ready to publish and/or package your software at any point in the future. Ugly hacks are like knives - dangerous when used inappropriately.