TOC   Previous   Next

Upgrading Shared Libraries

Note: A new major or minor version of a library can be installed, even while running programs are making use of an existing version.

Example - upgrading a shared library with a new minor version (1.0.2):

# gcc -fPIC -g -c -Wall mod1.c mod2.c mod3.c
# gcc -shared -Wl,-soname,libdemo.so.1 -o libdemo.so.1.0.2 \
        mod1.o mod2.o mod3.o
# mv libdemo.so.1.0.2 /usr/lib
# ldconfig -v | grep libdemo
        libdemo.so.1 -> libdemo.so.1.0.2 (changed)

Assuming the linker name was already correctly set up, we do not need to modify it.

Then upgrading to a new major version (2.0.1):

# gcc -fPIC -g -c -Wall mod1.c mod2.c mod3.c
# gcc -shared -Wl,-soname,libdemo.so.2 -o libdemo.so.2.0.1 \
        mod1.o mod2.o mod3.o
# mv libdemo.so.2.0.1 /usr/lib
# ldconfig -v | grep libdemo
        libdemo.so.1 -> libdemo.so.1.0.2
        libdemo.so.2 -> libdemo.so.2.0.1 (changed)      
# cd /usr/lib
# ln -sf libdemo.so.2 libdemo.so     

ldconfig automatically creates a soname symbolic link, but we must manually update the linker name symbolic link.

(C) 2006, Michael Kerrisk