Invoking cl.exe (MSVC compiler) in Cygwin shell

前端 未结 12 2219
执念已碎
执念已碎 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:37

    None of the other answers worked for me, but this did:

    1. Run "MS Build Command Prompt"

    1. dump the env vars: set > c:\temp\cl.env

    2. Open a cygwin command prompt and create a source script:

    awk < /cygdrive/c/temp/cl.env -F= '{ if($1 !~ ")") print "export " $1 "=\x27" $2 "\x27" }' > cl.source
    
    1. Modify cl.source to change TEMP and TMP to C:\Temp e.g. TEMP='C:\Temp'

    2. Now, whenever you need the cl environment, from your cygwin prompt run: source cl.source

    3. Optionally, source cl.source in your .bashrc file to run automatically when you log in

提交回复
热议问题