I usually solve this by adding
call "%VS80COMNTOOLS%vsvars32.bat" >NUL:
to c:/cygwin/cygwin.bat. Note that the VS80COMNTOOLS variable is extremely useful, since it gives you a foolproof (hm) way of locating vsvars32.bat.
Another approach is this, which allows you to easily switch between different Studio versions:
function run_with_bat()
{
batfile=$1; shift
tmpfile="$TMP/tmp$$.bat"
echo "@echo off" > $tmpfile
echo "call "%$batfile%vsvars32.bat" >NUL:" >> $tmpfile
echo "bash -c "%*"" >> $tmpfile
cmd /c `cygpath -m "$tmpfile"` "$@"
status=$?
rm -f $tmpfile
return $status
}
function run_vs9()
{
run_with_bat VS90COMNTOOLS "$@"
}
function run_vs8()
{
run_with_bat VS80COMNTOOLS "$@"
}
You can now do:
$ run_vs8 cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
$ run_vs9 cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
Note the compiler version.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…