问题
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:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/2296101/file-version-information