Search code examples
linuxdependenciesshared-librariesmysql++

Linux application - minimize the dependencies


I am trying to minimize the dependencies caused by the shared library mysql++. I know it sounds strange; but I am struggling to solve a platform limitation on Slamd64 ( with 32bit compatibility installed ), where it natively doesn't have certain libraries. I am in a situation where I cannot alter the setup of libmysqlclient due to dependencies to other applications.

Instructions to make mysql++ library link statically to it dependencies, that's what I am trying to do. NOT trying to link statically my application to mysql++; I still want to link dynamically to mysql++.


Solution

  • This is not very easy. You will need to

    1. get a list of .a libraries, which are needed for distibution (don't add here system installed libs, like libc.a)
    2. compile all .a staticly, but with -fPIC enabled
    3. link all .a into one .so
    4. check, can you ldd this .so and load it into application

    There can be a workaround with using ENV LD_LIBRARY_PATH and LD_PRELOAD. They can help you to mask out system-wide library and point application to your libs. Just google for this variables.