I made a simple program that uses a shared object, opening it with dlopen()
. I also compiled and linked the shared object like below:
gcc -o libmylib.so libmylib.c -shared -fPIC -Wall
gcc -o program program.c -L. -lmylib -ldl -Wall
When I tried to run the program for the first time it said something like
cannot open libmylib.so: no such file or directory
so I searched the internet and found that I have to copy my shared object to /lib/i386-linux-gnu/
in order for the program to run. So I did so, and it worked, but then I tried to do it in other ways and therefore I removed libmylib.so
from the /lib/i3686-linux-gnu/
directory. Now when I'm trying to run the program it shown no errors but keeps saying Segmentation fault
. It is clear that the shared object is nowhere to be found, but how can I link it without copying anything?
I am using Ubuntu 11.10