How can I store a version number in a static library (file.a) and later check for its version in Linux?
P.S. I need possibility to check version of file any time wit
If you are using gcc, you can use the #ident directive
#ident "Foo Version 1.2.3.4"
void foo(void){ /* foo code here */ }
To get the version just use one of the following:
strings -a foo.o | grep "Foo Version"
strings -a foo.a | grep "Foo Version"
strings -a foo.so | grep "Foo Version"
This will allow you to compile the version into the library with the capability of later stripping it out using strip -R .comment your_file
or completely omit it by passing -fno-ident
(This will also omit the compiler version comments from the compiled objects)