Reputation: 4624
I have a code base that I am compiling in to a library. Normally I would send the library as MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
but my customer is asking for it as MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
.
I have downloaded/installed and compiled new versions of my lib with Visual Studio 2012. Now I want to check the lib to see what _MSC_VER
version it is currently using to ensure that I am sending them the correct version.
How do you detect what _MSC_VER
is used in a library?
Upvotes: 5
Views: 2056
Reputation: 42032
_MSC_VER
is a macro which only exists in LIB or OBJ files for determining linking capabilities, so you can't use dumpbin PEfile /rawdata | find "_MSC_VER"
for compiled EXE or DLL files. In that case you need to check the dependency by running
dumpbin /dependents PEfile
Look for the MSVC*.dll
or VCRUNTIME*.dll
in the dependency list. The number after that is the VC redistributable version
PS C:> dumpbin.exe /dependents C:\qpdf17.dll [...] Image has the following dependencies: ADVAPI32.dll MSVCP120.dll MSVCR120.dll KERNEL32.dll [...] PS C:> dumpbin.exe /dependents C:\qpdf26.dll [...] Image has the following dependencies: ADVAPI32.dll MSVCP140.dll KERNEL32.dll VCRUNTIME140.dll VCRUNTIME140_1.dll [...] PS C:>
In the above example MSVCP120 is from MSVC++ 12.0 which means Visual Studio 2013 and _MSC_VER=1800
. Similarly VCRUNTIME140 is from MSVC++ 14.0 which means Visual Studio 2015 and _MSC_VER=1900
. You can check the version and _MSC_VER
values here
Sometimes the /rawdata
option won't even work on LIB or OBJ files. I redirected the output to file and saw that the output is truncated in the middle for some unknown reason. The /dependents
option also doesn't work for them. In that case you need to use another way. If you have GNU tools then you can run either of the below
strings OBJ_or_LIB.file | grep -Po '_MSC_VER=\d+'
grep -aPo '_MSC_VER=\d+' OBJ_or_LIB.file
Or you can also use this PowerShell command
sls -Ca '_MSC_VER=\d+' OBJ_or_LIB.file |% {$_.matches} | select value
or the full command:
Select-String -CaseSensitive '_MSC_VER=\d+' OBJ_or_LIB.file |
ForEach-Object {$_.matches} |
Select-Object value
Upvotes: 0
Reputation: 346
You might be able to try dumpbin.
c:\dev\tagainijisho>dumpbin C:\Qt\5.4\msvc2010_opengl\lib\qtmaind.lib /rawdata | find "_MSC_VER"
00000040: 3A 22 5F 4D 53 43 5F 56 45 52 3D 31 36 30 30 22 :"_MSC_VER=1600"
Upvotes: 5