Finding Version of Microsoft C++ Compiler from Command-Line (For Makefiles)

Finding version of Microsoft C++ compiler from command-line (for makefiles)

Are you sure you can't just run cl.exe without any input for it to report its version?

I've just tested running cl.exe in the command prompt for VS 2008, 2005, and .NET 2003 and they all reported its version.

For 2008:

d:\Program Files\Microsoft Visual Studio 9.0\VC>cl

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

For 2005, SP 1 (added Safe Standard C++ classes):

C:\Program Files\Microsoft Visual Studio 8\VC>cl

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86

For 2005:

C:\Program Files\Microsoft Visual Studio 8\VC>cl

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86

For .NET 2003:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86

EDIT

For 2010, it will be along the line of:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.XX.YYYYY.ZZ for 80x86

or depending on targeted platform

Microsoft (R) C/C++ Optimizing Compiler Version 16.XX.YYYYY.ZZ for x64

For 2012:

Microsoft (R) C/C++ Optimizing Compiler Version 17.XX.YYYYY.ZZ for $$$

where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX, YYYYY, and ZZ are minor version numbers.

For 2013:

Microsoft (R) C/C++ Optimizing Compiler Version 18.XX.YYYYY.ZZ for $$$

where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX, YYYYY, and ZZ are minor version numbers.

For 2015:

Microsoft (R) C/C++ Optimizing Compiler Version 19.XX.YYYYY for $$$

where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX and YYYYY are minor version numbers.

Makefiles for Microsoft Visual C++

Solved! Answering myself, so that if anyone intend to compile makefiles using nmake for Visual C++ compiler.

Yes, it is compiles in older version of visual C++ also. I have tested and it works fine. But it may cause problems when some properties are use of latest visual C++ compiler. Because you will not find those properties in older version of C++ compiler. Otherwise it is quite OK.

Is there a way to determine which version of Visual Studio was used to compile a static library?

For release libraries, it's unlikely that you could determine the version.

For debug libraries, you can use dumpbin:

dumpbin /rawdata:1 library.lib

The assembly manifest should be at the beginning of the dump and will contain the version of the CRT the library requires along with the full path to the compiler used to build the library.

For executables and DLLs you can get the linker version using dumpbin; it's under "OPTIONAL HEADER VALUES"

dumpbin /headers program.exe

Maybe someone else knows of a way to get the version for release libraries; I'm certainly interested too if they are.

Cannot compile Makefile using make command on Windows

I can't answer but maybe I can orient you.

First nmake is not make. It will not work with any makefile not written specifically as an nmake makefile. And it's only available on Windows. So, best to just forget it exists.

Second, it's important to understand how make works: rules in makefiles are a combination of targets/prerequisites, and a recipe. The recipe is not in "makefile" syntax, it's a shell script (batch file). So make works in tandem with the shell, to run commands. Which shell? On POSIX systems like GNU/Linux and MacOS it's very simple: a POSIX shell; by default /bin/sh.

On Windows systems it's much less simple: there are a lot of options. It could be cmd.exe. It could be PowerShell. It could be a POSIX shell, that was installed by the user. Which one is chosen by default, depends on how your version of make was compiled. That's why you see different behaviors for different "ports" of make to Windows.

So, if you look at the makefiles you are trying to use you can see they are unquestionably written specifically for a POSIX system and expect a POSIX shell and a POSIX environment. Any attempt to use a version of make that invokes cmd.exe as its default shell will fail immediately with syntax errors ("" was unexpected at this time.).

OK, so you find a version of make that invokes a POSIX shell, and you don't get that error anymore.

But then you have to contend with another difference: directory separators. In Windows they use backslash. In POSIX systems, they use forward slash and backslash is an escape character (so it's not just passed through the shell untouched). If you are going to use paths in a POSIX shell, you need to make sure your paths use forward slashes else the shell will remove them as escape characters. Luckily, most Windows programs accept forward slashes as well as backslashes as directory separators (but not all: for example cmd.exe built-in tools do not).

Then you have to contend with the Windows abomination known as drive letters. This is highly problematic for make because to make, the : character is special in various places. So when make sees a line like C:/foo:C:/bar its parser will get confused, and you get errors. Some versions of make compiled for Windows enable a heuristic which tries to see if a path looks like a drive letter or not. Some just assume POSIX-style paths. They can also be a problem for the POSIX shell: many POSIX environments on Windows map drive letters to standard POSIX paths, so C:\foo is written as /c/foo or /mnt/c/foo or something else. If you are adding paths to your makefile you need to figure out what the right mapping, if any, is and use that.

That's not even to start discussing the other differences between POSIX and Windows... there are so many.

From what you've shown above, this project was not written with any sort of portability to Windows in mind. Given the complexity of this, that's not surprising: it takes a huge amount of work. So you have these options that I can see:

  1. Port it yourself to be Windows-compatible
  2. Try to get it working inside cygwin (cygwin is intended to be a POSIX-style environment that runs on Windows)
  3. Try to get it working in WSL
  4. Install a virtual machine using VMWare, VirtualBox, etc. running a Linux distribution and build and run it there

Unfortunately I don't know much about the pros and cons of these approaches so I can't advise you as to the best course.

The route I chose, long long ago, was to get rid of Windows entirely and just use GNU/Linux. But of course that won't be possible for everyone :).

MSVC - do not display compiler version/copyright information

As suggested by @dxiv in the comments, adding /nologo flag seems to have worked. The modified makefile is:

all: hello.cpp
cl /EHsc /nologo hello.cpp

The output on the developer powershell is:

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

cl /EHsc /nologo hello.cpp
hello.cpp

I don't know why does microsoft feel the need to display this (compiler version and copyright information) information by default as it is completely unnecessary. If I need the compiler version for debugging I should be able to do something like cl -v similar to g++ for UNIX. More flags can be found here.



Related Topics



Leave a reply



Submit