Invoking cl.exe (MSVC compiler) in Cygwin shell

前端 未结 12 2252
执念已碎
执念已碎 2020-12-04 16:50

I\'m heavily using Cygwin (with PuTTY shell). But, it\'s quite tricky to invoke cl.exe (that is, the Visual C++ compiler toolchain) in the Cygwin Bash shell. R

12条回答
  •  余生分开走
    2020-12-04 17:39

    My version of Igor's solution, it's briefer:

    cl() {
      tmpfile="/tmp/tmp$$.bat"
      echo "@echo off" > $tmpfile
      echo "call \"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat\" >NUL:" >> $tmpfile
      echo "bash -c \"cl %*\"" >> $tmpfile
      cmd /c `cygpath -m "$tmpfile"` "$@"
      status=$?
      rm -f $tmpfile
      return $status
    }
    

    it's a pity that vcvars64.bat needs to be called repetitively.

提交回复
热议问题