从命令行查找 Microsoft C++ 编译器的版本(用于生成文件) [英] Finding version of Microsoft C++ compiler from command-line (for makefiles)

查看:136
本文介绍了从命令行查找 Microsoft C++ 编译器的版本(用于生成文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一定遗漏了一些非常明显的东西,但出于某种原因,Microsoft C++ 编译器 (cl.exe) 的命令行版本似乎不支持在运行时仅报告其版本.我们需要这个来编写检查我们工具用户安装的编译器版本的生成文件(他们获得带有代码的生成文件,他们将在本地编译自己,所以我们无法控制他们的编译器版本).

I must be missing something really obvious, but for some reason, the command-line version of the Microsoft C++ compiler (cl.exe) does not seem to support reporting just its version when run. We need this to write makefiles that check the compiler version a user of our tool has installed (they get makefiles with code they are to compile themselves locally, so we have no control over their compiler version).

在 gcc 中,您只需提供选项 -v 或 --version 即可打印出不错的版本字符串.

In gcc, you just give the option -v or --version to get a nice version string printed.

在 cl.exe 中,您收到 -v 错误.

In cl.exe, you get an error for -v.

我已阅读 MSDN 文档和编译器在线帮助,但找不到仅打印编译器版本的开关.令人讨厌的是,您总是在编译器启动时获取版本......但您似乎无法启动编译器只是为了从中获取版本.

I have read the MSDN docs and compiler online help, and I cannot find the switch to just print the compiler version. Annoyingly, you always get the version when the compiler starts... but you seem not to be able to start the compiler just to get the version out of it.

使用 qmake 查找编译器供应商/版本 看起来很相似,但只是交易与 gcc 的简单情况.

Finding compiler vendor / version using qmake seemed similar, but only deals with the simple case of gcc.

如果这很重要,我正在尝试使用 VC++ Express 2005.我希望它不会,因为最好以独立于编译器版本的方式检测编译器版本:)

I am trying this with VC++ Express 2005, if that matters. I hoped it would not, as detecting the compiler version is best done in a compiler-version-independent way :)

回复后更新:

  • 不带任何参数运行 cl.exe打印它的版本和一些帮助文本.
  • 这看起来最像获取版本的便携方式,跨 vc 版本.
  • 然后你必须解析多行输出,但是不是太难.
  • 我们在结束,它起作用了.

推荐答案

你确定不能在没有任何输入的情况下运行 cl.exe 让它报告其版本吗?

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

我刚刚测试了在 VS 2008、2005 和 .NET 2003 的命令提示符下运行 cl.exe,他们都报告了它的版本.

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

2008 年:

d:Program FilesMicrosoft Visual Studio 9.0VC>cl

d:Program FilesMicrosoft Visual Studio 9.0VC>cl

Microsoft (R) 32 位 C/C++ 优化编译器版本 15.00.30729.01 for 80x86

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

对于 2005,SP 1(添加了安全标准 C++ 类):

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

C:Program FilesMicrosoft Visual Studio 8VC>cl

C:Program FilesMicrosoft Visual Studio 8VC>cl

Microsoft (R) 32 位 C/C++ 优化编译器版本 14.00.50727.762 for 80x86

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

2005 年:

C:Program FilesMicrosoft Visual Studio 8VC>cl

C:Program FilesMicrosoft Visual Studio 8VC>cl

Microsoft (R) 32 位 C/C++ 优化编译器版本 14.00.50727.42 for 80x86

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

对于 .NET 2003:

For .NET 2003:

Microsoft (R) 32 位 C/C++ 优化编译器版本 13.10.6030 for 80x86

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

编辑

对于 2010 年,它将沿着以下路线:

For 2010, it will be along the line of:

Microsoft (R) 32 位 C/C++ 优化编译器版本 16.XX.YYYYY.ZZ for 80x86

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

或取决于目标平台

Microsoft (R) C/C++ 优化编译器版本 16.XX.YYYYY.ZZ for x64

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

2012 年:

Microsoft (R) C/C++ 优化编译器版本 17.XX.YYYYY.ZZ for $$$

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

其中 $$$ 是目标平台(例如 x86、x64、ARM),XX、YYYYY 和 ZZ 是次要版本号.

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

2013 年:

Microsoft (R) C/C++ 优化编译器版本 18.XX.YYYYY.ZZ for $$$

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

其中 $$$ 是目标平台(例如 x86、x64、ARM),XX、YYYYY 和 ZZ 是次要版本号.

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

2015 年:

Microsoft (R) C/C++ 优化编译器版本 19.XX.YYYYY for $$$

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

其中 $$$ 是目标平台(例如 x86、x64、ARM),XX 和 YYYYY 是次要版本号.

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

这篇关于从命令行查找 Microsoft C++ 编译器的版本(用于生成文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆