Shared libraries

Remember

gcc -shared -Wl,-soname,your_soname -o library_name file_list library_list

Which means, if you have a.c and b.c

gcc -fPIC -g -c -Wall a.c
gcc -fPIC -g -c -Wall b.c
gcc -shared -Wl,-soname,libmystuff.so.1 \
-o libmystuff.so.1.0.1 a.o b.o -lc


Then create the symbolic links to libmystuff.so and libmystuff.so.1 from libmystuff.so.1.0.1 and don't forget to add the libraries to the standard path /usr/local/lib OR add the path to LD_LIBRARY_PATH before executing.

More details: Creating shared libraries
Very good How-To: Link

2 comments:

Athira said...

Ahem! :)

Piyush Garyali said...

This one was for you, so that you don't have to hunt for it again :)