Midl找不到C预处理程序cl.exe [英] midl cannot find C preprocessor cl.exe

查看:168
本文介绍了Midl找不到C预处理程序cl.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用midl编译arith.idl文件.我正在运行Windows 7专业版.

I am trying to compile my arith.idl file with midl. I am running windows 7 pro.

这是我在Powershell提示符中启动的命令:

Here is the command I launch in a powershell prompt:

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编程非常了解,非常感谢您的帮助.我已阅读,但这不能解决任何问题(相同的症状).我也尝试过使用以下命令指定预处理器cl.exe:

I am quite a noob at windows RPC programming, I would highly appreciate some help. I have read this but this does not resolve anything (same symptoms). I have also tried specifying the preprocessor cl.exe with this command:

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:\>

此命令不返回任何内容,并且

This command does not return anything and

echo $?

返回False

执行vcvarsall.bat文件不会更改任何内容.这是我启动的powershell命令的输出:

The execution of the vcvarsall.bat file does not change anything. Here is the output of the powershell command I launched:

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:\>

推荐答案

不久前,我写了一篇有关此的文章.从PowerShell运行Cmd.exe Shell脚本(批处理文件)时,环境变量更改不会传播到父进程(PowerShell).要解决此问题,您需要在Shell脚本完成后捕获环境变量的更改.这篇文章是这样的:

I wrote an article about this not too long ago. When you run a Cmd.exe shell script (batch file) from PowerShell, environment variable changes do not propagate to the parent process (PowerShell). To work around this, you need to capture the environment variable changes after the shell script completes. The article is this one:

Windows IT Pro:在PowerShell中负责环境变量

您可以使用该文章中的Invoke-CmdScript函数运行vcvarsall.bat并将其环境变量更改传播到PowerShell.

You can use the Invoke-CmdScript function from that article to run vcvarsall.bat and propagate its environment variable changes to PowerShell.

Invoke-CmdScript看起来像这样:

Invoke-CmdScript looks like this:

function Invoke-CmdScript {
  param(
    [String] $scriptName
  )
  $cmdLine = """$scriptName"" $args & set"
  & $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
  select-string '^([^=]*)=(.*)$' | foreach-object {
    $varName = $_.Matches[0].Groups[1].Value
    $varValue = $_.Matches[0].Groups[2].Value
    set-item Env:$varName $varValue
  }
}

如果要在PowerShell脚本中本地化环境变量更改,也可以使用该文章中的Get-Environment和Restore-Environment函数.

You can also use the Get-Environment and Restore-Environment functions from that article if you want to localize the environment variable changes in your PowerShell script.

这篇关于Midl找不到C预处理程序cl.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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