3 ms·
Really bad consequence of the current/same directory being in the library search path. It's similar to why, on Linux/Unix, it's bad practice to include "." in
by kelnos 11y ago
Really bad consequence of the current/same directory being in the library search path. It's similar to why, on Linux/Unix, it's bad practice to include "." in your PATH (or LD_LIBRARY_PATH). I know including same-directory libraries can make things more convenient, but it should be something that an app explicitly needs to want and enable, not something that just happens.
- meanduck 11y agoIMO, loading by hash and/or sign are better solution.
- deleted 11y ago[deleted]
- sltkr 11y ago> It's similar to why, on Linux/Unix, it's bad practice to include "." in your PATH (or LD_LIBRARY_PATH). An even trickier problem on Linux is that an empty component in the LD_LIBRARY_PATH is interpreted as a reference to the cwd. Many tools come with launcher scripts that do something like: export LD_LIBRARY_PATH=/usr/local/lib/my-app-1.0:${LD_LIBRARY_PATH} /usr/local/bin/my-app-1.0 ... and bam, now if $LD_LIBRARY_PATH was empty (which it usually is) you've unintentionally added the cwd to it. This problem is fairly common in practice. FWIW, the correct way to set the variable is: export LD_LIBRARY_PATH=/usr/local/lib/my-app-1.0${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} (or make sure the binary has a DT_RUNPATH entry that points to the library directory, so you don't have to mess around with environmental variables at all.)
- coldpie 11y agoI wonder if changing this behavior would break anything. I can't imagine too much software relies on it.