Skip to content

Instantly share code, notes, and snippets.

@0xef967c36 0xef967c36/solibs-test

Last active Apr 11, 2020
What would you like to do?
solibs with DT_RUNPATH example
mkdir -p b a
echo 'void b(){ puts("b"); }' > b.c
cc -include stdio.h -shared b.c -o b/
echo 'int main(){ extern void b(); b(); }' > m.c
cc m.c -o m -Wl,-rpath=./b -L ./b -lb
# => b
# now we create a _different_ b/ linking to a a/
# the ./m doesn't know about
echo 'void a(){ puts("a"); }' > a.c
cc -include stdio.h -shared a.c -o a/
echo 'void b(){ extern void a(); a(); }' > b.c
cc -shared -Wl,-rpath=./a b.c -L ./a -la -o b/
# => a
rm a/
# => ./m: error while loading shared libraries: cannot open shared object file: No such file or directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.