views:

357

answers:

2

I am wondering what are the possible value for *_la_LDFLAGS in Makefile.am ?

If I ask this question, it is because I would like the following :

Actual shared library : libA.so (or with the version number I don't care)
Symbolic links :        libA-X.Y.Z.so, libA-X.so, libA.so 
soname :                libA-X.so

However here is what I get by using the -release flag :

Actual shared library : libA-X.Y.Z.so
Symbolic links :        libA.so 
soname :                libA-X.Y.Z.so    !!! this is not what I want

I also tried with no flags at all and got

Actual shared library : libA-0.0.0.so    !!! 0.0.0 and not the real version
Symbolic links :        libA.so, libA-0.so
soname :                libA-0.so        !!! 0.0.0 and not the real version

How should I do ? which flag should I use ?

Thanks in advance

+2  A: 

You should use the -version-info option of Libtool to specify the interface version of the library, but be sure to read how versioning works (or here for the official manual.)

You can additionally play with -release to make the version number of your package more apparent, but I doubt you will ever get the exact naming you'd like. Libtool has its own set of rules to define how to name the file and what symlinks to create depending on the system: these should really be regarded as implementation details of how a shared library is installed.

adl
+1  A: 

IMHO, the layout you want is broken. Apps that are linked to your library will depend on libA-X.so because of the soname. But what happens when libA.so is version X+1? To what will the libA-X.so symlink point?

The idea behind the layout you get with the -release flag is, when an app links with -lA, it will result in it being linked against the latest version. It will then, because of the soname, depend on libA-X.Y.Z.so at runtime. When you install a new version of the library, that will install a new libA-X.Y.Q.so, but it will leave the old one alone - exactly as old apps that depend on it expect. New apps will still, because of the libA symlink, link against the latest version.

Years of thought by some very smart people have went into a versioning scheme that allows new apps to link against the latest version of a library, while allowing multiple versions to co-exist peacefully to satisfy dependencies for apps that need them. My advice is, don't second-guess all that.

Sherm Pendley
Well, I understand what you say. However, imagine that I have a library B linked against libA-X.Y.Z.so and I release libA-X.Y.Q.so. If I create RPM's and use YUM, I have to specify for package B that libA = X.Y.Z instead of libA >= X.Y.Z, and I have a feeling that it is too restrictive as ...
Barth
lib B could use the higher version without problem. You can see this other question to understand better what bother me with the use of -release : http://stackoverflow.com/questions/252819/c-how-to-link-against-libaso-and-not-liba-xyzso
Barth