tags:

views:

269

answers:

3

Im using a market data source implementation that contains .so.0 files. However these are 'soft links' to actual .so.0.0.0 files. Why is this done?

When I try to copy these .so.0 links, it ends up copying an exact replica of the .so.0.0.0 file but with a .so.0 prefix.

Added comment:

so I have a libfoo.so file, and it is being accessed by java through jni. This libfoo.so file is actually a soft link that points to libfoo.so.0.0.0 What happens if I don't have libfoo.so. How does java/or any other compiled code, figure out that libfoo.so.0.0.0 if the shared object to use?

+6  A: 

This is so programs can bind to either any version of libfoo that has the same interface (I want the latest updates to libfoo), or bind to a specific version (I want stability and only the exact version I tested against).

Paul Betts
so I have a libfoo.so file, and it is being accessed by java through jni. This libfoo.so file is actually a soft link that points to libfoo.so.0.0.0What happens if I don't have libfoo.so. How does java/or any other compiled code, figure out that libfoo.so.0.0.0 if the shared object to use?
Read the `ld` man page, if on Linux.
Robert Munteanu
If you have libfoo.so.0.0.0 you should always have libfoo.so.0 and libfoo.so, this is part of how libtool works; if it doesn't exist, they're generating the libraries wrong
Paul Betts
+2  A: 

The .0 and .0.0.0 files exist so that versioning can happen:

  • foo.0 represents the .0 version of a library. All .0 versions of the library will use the same interface, but there may be different implementations. (Hopefully, the later implementations will have fewer bugs than the earlier ones.)

  • foo.0.0.0 represents a specific implementation of the .0 version.

It's not useful, now, to have the soft-link. But here's what could happen:

The programmer of foo finds a bug in his library. He releases foo.0.0.1. And foo.0 now links to foo.0.0.1. Then two things happen:

  • All files that link to foo.0 will automatically update to foo.0.0.1.
  • All files that link to foo.0.0.0 will continue to use the old foo.0.0.0
Chip Uni
Extend this a few levels further and you can require an exact version match by linking against `libfoo.0.0.0` or any matching interface version with `libfoo.0` or any version at all with `libfoo`.
D.Shawley
Apologise for the basic question, but how is this linking specified. How can I specify that jni should use libfoo.so and not libfoo.so.0.0.0?
Hihi, coder zambesi. Sadly, Java documents are not much help: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#loadLibrary(java.lang.String) says "The manner in which a library name is mapped to the actual system library is system dependent." There might be some help at http://stackoverflow.com/questions/1010503/how-to-debug-a-java-system-loadlibrary-error-in-linux Good luck.
Chip Uni
A: 

I struggled to understand this topic for a while; here's a good link that helped me make sense of it.

gareth_bowles