I'm working with JNI. I have a wrapper library (wrapper.so) that uses two shared libraries: one.so and two.so
Everything works fine. All *.so are in the lib folder, inside the program folder.
The problem is, if I copy this folder to another computer I get linking problems.
Let's say I run this on a machine user2 (/home/user2/program), and I compiled in a machine user1 (/home/user1/program), I get the linking error:
UnsatisfiedLinkError: /home/user1/program/lib/one.so
How I can make the linking of the libraries relative to the parent program folder (like, search for this_foler/lib ??
I'm compiling like:
g++ -c -o src/wrapper.o src/wrapper.c
g++ -shared -o wrapper.so src/wrapper.o one.so two.so
How I can make the linking of the libraries relative to the parent program folder
Depends on your operating system. On Linux, this will probably work:
g++ -shared -o wrapper.so -Wl,-rpath='$ORIGIN' src/wrapper.o one.so two.so
Note: single quotes are important in above command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With