[lug] Need help understanding linking and loading shared libraries

Michael Hirsch mdhirsch at gmail.com
Tue Feb 5 09:04:20 MST 2008


On Feb 4, 2008 6:28 PM, Hugh Brown <hugh at math.byu.edu> wrote:
>
> Michael Hirsch wrote:
> > I thought I mostly understood this, but I'm definitely missing something.
> >
> > I have a library, lets call it libboost.so.1.33.1, though the real
> > name is longer.  There is also a copy of this file named libboost.so
> >
> > I build my own library, lets call it libfoo.so which relies on
> > libboost.  The option to g++ is -lboost.
> >
> > Finally, I have an executable, bar, that needs libfoo.so (again, with -lfoo).
> >
> > All this works.  But now, if I only have libboost.so and not
> > libboost.so.1.33.1 the loader will complain that it can't file
> > libboost.so.1.33.1.  In fact, "ldd bar" reports libboost.so.1.33.1,
> > rather than libboost.so like I expected.
> >
> > I was under the impression that since libboost.so satisfies all the
> > link requirements for libfoo, that it would satisfy the loader.  Is
> > there something I've have done that makes libfoo.so know the exact
> > version number of the libboost.so library?  Is there a way to turn off
> > this exactness requirement?
> >
> > I expect I'm missing some seemingly trivial but crucial information,
> > but don't know what that is.
> >
> > Thanks,
> >
> > Michael
>
>
> Usually libboost.so is a symbolic link to the versioned library.  So if
> you link in -lboost it will use the target of the symbolic link (i.e.
> libboost.so.1.33.1).

Yes, I knew that.  But I believe that if, instead of linking, I just
rename libboost.so.1.33.1 to libboost.so, it should be able to use the
shorter name. I thought that was the whole point.  It allows the
system to have a minor upgrade to, say, libboost1.33.2 and still
resolve all the symbols.

 Apparently not, or not without some additional work.

Michael



More information about the LUG mailing list