Skip to content

Instantly share code, notes, and snippets.

@vtta
Created May 3, 2023 03:25
Show Gist options
  • Save vtta/6a4d8d6de25ffb12b90c4c35a434b6cc to your computer and use it in GitHub Desktop.
Save vtta/6a4d8d6de25ffb12b90c4c35a434b6cc to your computer and use it in GitHub Desktop.
rpath that allows searching library relative to its location

source

We can use the $ORIGIN "special" path to have a path relative to the executable with -Wl,-rpath,'$ORIGIN' in bash or -Wl,-rpath,'$$ORIGIN' in Makefile

note that you need quotes around it to avoid having the shell interpret it as a variable, and if you try to do this in a Makefile, you need $$ to avoid having make interpret the $ as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment