3 ms·
> You don't even need static linking, you can use LD_LIBRARY_PATH and a custom startup script in a lot of cases, it's just a lot more work than it should be and
by account42 5y ago
> You don't even need static linking, you can use LD_LIBRARY_PATH and a custom startup script in a lot of cases, it's just a lot more work than it should be and fails in weird ways because no one expects this kind of thing. Trust me, I've been doing this for years and years now.
You don't even need a startup script to adjust the library search path, ELF binaries have the DT_RUNPATH field for that where '$ORIGIN' refers to the directory containing the executable. Using the -Wl,-rpath,$ORIGIN flag when linking gives you more or less the Windows behavior, just make sure to escape the $ORIGIN appropriately so it is passed as is and not expanded by the shell/make/your build system. And if you want, you can even put libraries in a subdirectory.
- AnIdiotOnTheNet 5y agoYeah but that only works if you're compiling it yourself. LD_LIBRARY_PATH lets you get binaries working this way, at least sometimes.