- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A Windows version of Strings may be obtained from various sources, e.g.:
http://www.windows7library.com/blog/util/search-for-strings-within-executables/
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page