views:

49

answers:

3

Hi, I would like to know what is the way (if it is possible at all), to change the version information of a *.a files in Unix after the compilation. I know how to do it for Dll files in windows - but have no idea how to manage with it in Unix.

Thank you all!

+1  A: 

Static libraries don't have version information per se.

Ignacio Vazquez-Abrams
+3  A: 

Static libraries are just archives of .o files - they don't embed version themselves unless your code somehow publishes a symbol that holds version information.

Like:

int libFoo_version = 0x01000000;

Or you could use

char* libFoo_version = "1.0";

and afterwards use something like the strings libFoo.a | grep libFoo_version command in combination with sed to alter the version information.

Yet another option is to embed an empty file in the archive which name contains the version information. YMMV

Gregory Pakosz
Thanks,but how will the end users know that this contains the version info? Do I have to mention it explicitely?Isn't there a generic way?
rursw1
There is no generic way. You may want to provide an API to retrieve the version information.
Gregory Pakosz
Is ranlib a correct solution?
rursw1
I don't think so. As far as I remember, ranlib has been integrated into ar which makes me think it doesn't offer a solution to your problem.
Gregory Pakosz
A: 

If the version is part of the source code (for example, a string constant), then you can simply use sed to change it if the new version has the same length as the old one.

Aaron Digulla
Hi,I've been told that ranlib may do this work.Is it correct?Thanks!
rursw1
ranlib just creates an index of the symbols in the library (equivalent to `ar -s`).
Aaron Digulla