views:

74

answers:

2

How can I add version information to a file? The files will typically be executables, .so and .a files.

Note: I'm using C++, dpkg-build and Ubuntu 8.10 if any of those have support for this.

+1  A: 

For shared objects pass -Wl,soname,<soname> to gcc, or -soname <soname> to ld.

Executables and static libraries do not have version information per se, but you can add it to the filename if you like.

Ignacio Vazquez-Abrams
This perhaps should go as a different question, but why do they not have any version information?
Fredrik Ullner
That is an interesting question for which I do not have an answer.
Ignacio Vazquez-Abrams
@Fredrik: The raison d'etre for versioning is to provide backwards compatibility, so that a binary dynamically linked against libfoo can be run with a newer version of libfoo. For binaries and static libraries the above argument is irrelevant, and hence nobody has bothered to add any kind of version field to the object format.
janneb
A: 

Linux executables do not have version information like Windows have...the only way I can think of doing it is to create a static character string, which would be expanded by a version control tracking system such as rcs, cvs, svn, git, in which a certain identifier is expanded based on the person who checked-in the code, here's the example of rcs identifiers that is used...

static char *Id = "$Id$";
static char *Author = "$Author$";

The above strings when checked into a revision control system, they get expanded next time it gets checked out...

static char *Id = "Foo, v1.1, 2009-02-18, 13:13";
static char *Author = "foo";

And use the utility 'ident' which runs on the binaries, 'ident' looks for Revision Control Systems (rcs) identifiers within a binary.

Hope this helps, Best regards, Tom.

tommieb75