Question

I have a Native C++ Static Library. I am using Visual Studio 2012 in Windows and Eclipse in Linux.

Is there any Built-in functionality to give a Static Library Version information?

I tried following the same steps I took for my C++/CLI library but it doesn't seem to have any effect.

It builds but I don't see the version in any place.

How do you set versioning information to a Static Library?

  • Is there built-in functionality in Visual Studio to this purpose?
  • If not, What is the correct way for setting the Version information? Any best practices?
  • How do you do it for Linux? (I build my Library for windows as a *.lib file and for Linux as a .a file, I need to keep version information)

Update

This is the VersionInfo with the SpecialBuild that Paul Suggested. The field doesn't show in any place.

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 61,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x21L
#else
 FILEFLAGS 0x20L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040004b0"
        BEGIN
            VALUE "CompanyName", "TODO: <Company name>"
            VALUE "FileDescription", "TODO: <File description>"
            VALUE "FileVersion", "61.0.0.1"
            VALUE "InternalName", "ExxonMobil.Rapid.Services.TEM"
            VALUE "LegalCopyright", "Copyright (C) 2014"
            VALUE "OriginalFilename", "ExxonMobil.Rapid.Services.TEM"
            VALUE "ProductName", "TODO: <Product name>"
            VALUE "ProductVersion", "1.0.0.1"
            VALUE "SpecialBuild ", "Blah"           
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x400, 1200
    END
END
Was it helpful?

Solution

As far as I know, there is no specific version information for static libraries, since a static library is part of the entire application.

What you could do is use one of the existing VersionInfo entries, maybe SpecialBuild, that lists the version of the static library used to build the application. Of course, you will have to invent a version numbering system for the static library.

There is one issue with the "SpecialBuild" entry, and that is that the VersionInfo viewer that comes with the Windows OS (open Explorer, right click on an executable file to bring up the context menu, choose "Properties" and go to the "Details tab) doesn't show the SpecialBuild information. This to me is an oversight from Microsoft.

There are third party viewers such as this one that shows the resource information: http://www.naughter.com/versioninfo.html. If this is not an option, there are other string fields in the version information that you can use to store additional information.

OTHER TIPS

You can include your compile time, or any version string of your choice, in .obj and .lib files using

#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )

See the MSDN documentation

It's not going to appear in any obvious location, though, like file properties for the .lib

Probably more useful is to have a function that returns the version string, that way applications that link with the library can display the version in their "About" dialogs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top