http://man7.org/conf/lca2006/shared_libraries/slide4b.html
The shared library soname (cont.)
Here's how to use a soname:
- Specify soname when creating shared library:
$ gcc -fPIC -c -Wall -g mod1.c mod2.c mod3.c $ gcc -shared -Wl,-soname,libbar.so -o libfoo.so mod1.o mod2.o mod3.o
- Create executable:
$ gcc -g -Wall -o prog prog.c libfoo.so
- Run the program:
$ LD_LIBRARY_PATH=. ./prog ./prog: error in loading shared libraries: libbar.so: cannot open shared object file: No such file or directory
- Create a symbolic link from the soname to the real name of the library:
$ ln -s libfoo.so libbar.so $ LD_LIBRARY_PATH=. ./prog Called mod1-x1 Called mod2-x2