Telling the linker to ignore missing libs - Unix

This is a discussion on Telling the linker to ignore missing libs - Unix ; Hi, I want to modify a library (libldap) to call a my own getaddrinfo function (packaged in libmyresolv). The problem is that libmyresolv links with a slew of other libs which creates a number of linking issues (one of the ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Telling the linker to ignore missing libs

  1. Telling the linker to ignore missing libs

    Hi,

    I want to modify a library (libldap) to call a my own getaddrinfo function
    (packaged in libmyresolv). The problem is that libmyresolv links with
    a slew of other libs which creates a number of linking issues (one of
    the libs links with libldap, libldap's build tries to link test programs,
    etc).

    Ultimately everything is going to be linked together into one big shared
    library anyway so I don't care about undefined references linking just
    libldap.so.

    Is there a way to tell the linker to just ignore missing libs lines
    so I can link libldap.so without dragging in all the linking options
    for libmyresolv?

    I'm using the standard GNU toolchain and all libs are PIC.

    Any advice would be appreciated. [As you can probably tell I'm basically
    trying to provide my own getaddrinfo. If you have any general advice on
    doing that then I would appreciate that too.]

    Mike

  2. Re: Telling the linker to ignore missing libs

    Michael B Allen writes:

    > Is there a way to tell the linker to just ignore missing libs lines
    > so I can link libldap.so without dragging in all the linking options
    > for libmyresolv?


    When linking a shared library, most UNIX linkers *already* ignore
    any unresolved symbols [1], so all you should have to do is
    simply drop the libraries you do not want from the link command line.

    > Any advice would be appreciated.


    It's not clear what your difficulty is, so it's hard to give advice.

    Cheers,

    [1] Unless you specified something like '-Wl,--no-undefined' or
    '-Wl,-z,defs'; in which case remove that option.
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: Telling the linker to ignore missing libs

    On Wed, 17 Oct 2007 20:37:42 -0700
    Paul Pluzhnikov wrote:

    > Michael B Allen writes:
    >
    > > Is there a way to tell the linker to just ignore missing libs lines
    > > so I can link libldap.so without dragging in all the linking options
    > > for libmyresolv?

    >
    > When linking a shared library, most UNIX linkers *already* ignore
    > any unresolved symbols [1], so all you should have to do is
    > simply drop the libraries you do not want from the link command line.


    Hey Paul,

    After a little more investigation it seems the real problem is the
    libldap's build creates all sorts of test programs which *do* need to
    resolve symbols in other libs. And it uses a GNU "configure" script so I'm
    not even going to try to hack it. So I guess I need to build libmyresolv
    first which even though it has a dependency on libldap should be able
    to build. Then I can build libldap linked with libmyresolv. I thought
    I tried that already and ran into a problem but I'll explore that again.

    Thanks for your help,
    Mike

  4. Re: Telling the linker to ignore missing libs

    On Wed, 17 Oct 2007 23:21:12 -0400, Michael B Allen wrote:
    > I want to modify a library (libldap) to call a my own getaddrinfo function
    > (packaged in libmyresolv). The problem is that libmyresolv links with
    > a slew of other libs which creates a number of linking issues (one of
    > the libs links with libldap, libldap's build tries to link test programs,
    > etc).


    This sounds like a circular dependency a lot. You'll have to, somehow,
    "break" the circle.

    > Ultimately everything is going to be linked together into one big shared
    > library anyway so I don't care about undefined references linking just
    > libldap.so.
    >
    > Is there a way to tell the linker to just ignore missing libs lines
    > so I can link libldap.so without dragging in all the linking options
    > for libmyresolv?
    >
    > I'm using the standard GNU toolchain and all libs are PIC.
    >
    > Any advice would be appreciated. [As you can probably tell I'm basically
    > trying to provide my own getaddrinfo. If you have any general advice on
    > doing that then I would appreciate that too.]


    Isn't it easier to build a library which provides *just* getaddrinfo()
    [and anything else this one requires to work properly], and then using
    LD_PRELOAD to preload it?

    env LD_PRELOAD=`pwd`/../lib/libcompat.so ./test1


+ Reply to Thread