简体   繁体   中英

Get Windows nmake version from command prompt?

I don't really know nmake , but I use nmake from "x64 Native Tools Command Prompt for VS 2017" under Windows 10; I would like to find out the version of this tool from the command prompt.

I have found this:

https://docs.microsoft.com/en-us/cpp/build/reference/batch-mode-rules?view=vs-2019

To check the NMAKE version, run the _NMAKE_VER macro available with NMAKE version 1.62 or higher. This macro returns a string representing the Visual C++ product version.

... but I don't really know how to "run the macro" - I tried this:

C:\>nmake _NMAKE_VER

Microsoft (R) Program Maintenance Utility Version 14.16.27026.1
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1073: don't know how to make '_NMAKE_VER'
Stop.

So, it dropped something like a version string, but there's still an error.

Thus, how can I get the nmake version from the command line properly?

As Hans Passant suggests, you could consider typing nmake/? ; this will give you what you already know from your question, namely 14.16.27026.1 .

The point of the variable _NMAKE_VER is to allow you to test the nmake version, or the Visual Studio version, from within the makefile. For example, suppose your makefile is:

 # Check the first three characters of _NMAKE_VER to
 # obtain the Visual Studio version:
 !if [cmd /c if "%_NMAKE_VER:~0,3%"=="14." exit 1]
 !  message Using VS 2017, with NMAKE $(_NMAKE_VER)
 !elseif [cmd /c if "%_NMAKE_VER:~0,3%"=="12." exit 1]
 !  message Using VS 2013, with NMAKE $(_NMAKE_VER)
 !else
 !  message Unknown VS version, with NMAKE $(_NMAKE_VER)
 !endif

 # Just output _NMAKE_VER:
 all:
      @echo "Version             NMAKE" $(_NMAKE_VER)

Then issuing the following command from the Visual Studio 2017 Developer Command Prompt:

 nmake /nologo

will give (on my machine):

 Using VS 2017, with NMAKE 14.10.25019.0
 Version             NMAKE 14.10.25019.0

or for Visual Studio 2013:

 Using VS 2013, with NMAKE 12.00.21005.1
 Version             NMAKE 12.00.21005.1

We need to use the DOS cmd to inspect _NMAKE_VER , as nmake unlike gmake has limited string manipulation tools.

Edit: The above test will probably not be able to distinguish between VS 15 and VS 17, since the VS 17 nmake version number begins with 14 rather than the expected 15 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM