Unix Programming - Telling the linker to ignore missing libs

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2007 > Telling the linker to ignore missing libs





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Telling the linker to ignore missing libs
Michael B Allen

2007-10-18, 1:30 am

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
Paul Pluzhnikov

2007-10-18, 1:30 am

Michael B Allen <ioplex@gmail.com> 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.
Michael B Allen

2007-10-18, 1:25 pm

On Wed, 17 Oct 2007 20:37:42 -0700
Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> wrote:

> Michael B Allen <ioplex@gmail.com> writes:
>
>
> 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
Giorgos Keramidas

2007-10-19, 1:32 pm

On Wed, 17 Oct 2007 23:21:12 -0400, Michael B Allen <ioplex@gmail.com> 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

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com