Forced linking

Say I have a project that links with a shared object, libfoo.so. This file is a link to libfoo.1.so. The resulting executable will NEED libfoo.1.so at run time.

In 3 years from now I need to rebuild the same executable but in the mean time libfoo.so. got updated to libfoo.so.5. Naturaly on my development machine libfoo.so has become a link to libfoo.so.5. How can I make sure that I can rebuild the same executable against libfoo.so.1 and NOT libfoo.so ( .5 ). I try to force the build to use libfoo.so.1 but no luck so far.

  • Mario

mario,

one possibility I see is adding a symlink (e.g. libfoo.1.so) referencing libfoo.so.1 to your development machines lib directory.

In your application you can add foo.1 (instead of foo) as extra library. But maybe you don’t want to change your lib dir?

(I expect further problems as the old foo library might use other, out of date libs…)

Peter

I think I figure out a way. I will put libfoo.so and libfoo.so.1 in the libfoo_v1 directory and point the makefile to it. When v2 gets created I’ll have both file in libfoo_v2. The makefile will have the lib search path set to the proper library.

Thanks for the suggestion.

But what happens, if in 3 years the current libc.so points to libc.so.3 while the libfoo.so.1 requires libc.so.2? I guess, your application will load libc.so.2 AND libc.so.3 in this case. I doubt that this healthy…

In my eyes, version conflicts and the resulting dependency issues are one of the major (unsolved) problems in todays software industries.

  • Peter

Good point, in fact I don’t know. The easy solution would be to use a static library but it makes a 300K executable grow to 1.2M…

I think I can get around this issue because our software the OS, and external library are always bundle together. Hence in 3 years if we upgrade the software and are using a different version of the OS we would have to upgrade everything.

It seems to me we need a solution to force linking with a perticular version of a shared library.

Mario,

Of course you see where this is going <!-- s;-) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";-)" title="Wink" /><!-- s;-) -->.   Eventually, you will have to create a separate VM for every project, and even every version of every project.   With terabyte hard drives finally out, this should be no problem.

The best would be to draw a copy from the present and load it in The Matix if required. (you know the movie?)

If ever possible, newer versions of a libraries should always be backward compatible with older versions. If this is true, there is nothing wrong with linking the old application with a newer version of libfoo.so. If not, somebody has broken the interface (and should get punished for doing this :wink:).

  • Peter