midl cannot find C preprocessor cl.exe

后端 未结 1 781
忘掉有多难
忘掉有多难 2020-12-21 12:36

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

Here is the command I launch in a powershell prompt:

PS> \'C:\\Pro         


        
相关标签:
1条回答
  • 2020-12-21 13:31

    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:

    IT Pro Today: Take Charge of Environment Variables in 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 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
      }
    }
    

    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.

    0 讨论(0)
提交回复
热议问题