Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor III
4 Views

embed version info in shared object similar to resource file

Hello, I'd like to embed version number information in a shared object (.so) binary during compiling and linking.  It looks like there is not a resource file available on Linux like on Windows with a version.rc resource file.  When building a DLL on Windows I can include a version.rc resource file and use the rc.exe resource compiler to get the version.res file to link into the DLL.  In the DLL properties/Details it gives the File Version number as 1.0.0.0 (similar discussion in: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/281529 ).

Is there another approach used to embed version information for the shared object binary on Linux that can later be extracted by an external program?

I've seen that one convention on Linux is to append the version number to the .so file: libname.so.1.0.0

Perhaps I should add a few parameter statements in the Fortran to save the version numbers or string that could be accessed through an externally available routine to return the version information.

Thanks for your suggestions.
Greg T.

0 Kudos
3 Replies
Highlighted
4 Views

As you have noted, Linux

As you have noted, Linux doesn't have anything like Windows' "resources" for executables and shared libraries. The usual approach on Linux is to declare a character variable at program or module scope that begins with a particular set of delimiters, such as starting with $version$ and ending with %, with the version number in the string. You'll want to use initialization in the declaration, such as:

CHARACTER(20) :: Version="$version$1.0.0$"//CHAR(0)

to make sure it gets into the object file intact. Then one normally uses the "strings" utility to search for the delimiters. The trailing NUL is needed as strings won't recognize it otherwise.

Retired 12/31/2016
0 Kudos
Highlighted
New Contributor III
4 Views

Steve, thank you for pointing

Steve, thank you for pointing me to the Linux strings utility and for providing an example of the needed syntax.  Since our Fortran code is used to build DLLs on Windows and .so shared objects on Linux I try it on both platforms.  After more reading it looks like Windows does not have an equivalent to the "strings" utility, so I keep the resource file on Windows.

Regards,
Greg

0 Kudos
Highlighted
Black Belt
4 Views

A Windows version of Strings

A Windows version of Strings may be obtained from various sources, e.g.:

     http://www.windows7library.com/blog/util/search-for-strings-within-executables/

 

0 Kudos