【发布时间】:2015-04-26 09:59:29
【问题描述】:
我正在尝试使用 midl 编译我的 arith.idl 文件。我正在运行 Windows 7 专业版。
这是我在 powershell 提示符下启动的命令:
PS> 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\midl.exe' .\arith.idl
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
64 bit Processing .\arith.idl
midl : command line error MIDL1005 : cannot find C preprocessor cl.exe
PS>
我是 Windows RPC 编程的菜鸟,我非常感谢一些帮助。我已阅读 this 但这并不能解决任何问题(相同的症状)。我也试过用这个命令指定预处理器 cl.exe:
PS C:\> & 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\midl.exe' /cpp_cmd 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe' C:\Users\$e\Desktop\MIDL\arith.idl
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
Processing C:\Users\philippe.CHIBOLLO\Desktop\MIDL\arith.idl
PS C:\>
此命令不返回任何内容并且
echo $?
返回假
编辑:
vcvarsall.bat 文件的执行不会改变任何东西。这是我启动的 powershell 命令的输出:
PS C:\> & 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat'
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
PS C:\> & 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\midl.exe' /cpp_cmd 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe' C:\Users\$me\Desktop\MIDL\arith.idl
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
Processing C:\Users\$me\Desktop\MIDL\arith.idl
PS C:\> echo $?
False
PS C:\>
【问题讨论】:
-
显然您需要访问
cl.exe,它是Microsoft C/C++ 编译器。它是否带有 SDK,可能安装到不同的路径?如果您安装了 Visual Studio,它肯定就在那里。否则,您可以通过免费安装 Visual Studio Express 来获得它。 -
除非您首先运行设置环境变量的 shell 脚本(批处理文件),否则命令行工具将无法正常工作。 IIRC 该脚本被命名为
vcvarsall.bat。 -
感谢您的回复;我相应地编辑了我的问题
标签: windows powershell rpc midl