问题描述
我肯定缺少一些明显的东西,但是由于某种原因,Microsoft C ++编译器的命令行版本(cl.exe)似乎不支持仅在运行时报告其版本.我们需要这样做来编写makefile,以检查我们工具的用户已安装的编译器版本(它们会获得带有将在本地进行编译的代码的makefile,因此我们无法控制其编译器版本).
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查找编译器供应商/版本似乎很相似,但仅涉及与简单的海湾合作委员会的情况.
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版本.
- 然后您必须解析多行输出,但是不太困难.
- 我们在最后,就可以了.
- Running cl.exe without any argumentsprints its version and some helptext.
- This looks like the mostportable way to get at the version,across vc versions.
- You then have toparse a multi-line output, but thatis not too difficult.
- We did this inthe end, and it works.
推荐答案
您确定不能在没有任何输入的情况下运行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年:
用于80x86的Microsoft(R)32位C/C ++优化编译器版本15.00.30729.01
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):
用于80x86的Microsoft(R)32位C/C ++优化编译器版本14.00.50727.762
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
2005年:
用于80x86的Microsoft(R)32位C/C ++优化编译器版本14.00.50727.42
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
对于.NET 2003:
For .NET 2003:
编辑
对于2010年,它将遵循以下原则:
For 2010, it will be along the line of:
或取决于目标平台
2012年:
其中$$$是目标平台(例如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年:
其中$$$是目标平台(例如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年:
其中$$$$是目标平台(例如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 ++编译器的版本(用于makefile)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!