We wanted to replace the slow cygwin toolset with WSL for building our Windows executable.
Executables are built on Windows 10 VMs. Access is either through RDP for manual tests or using SSH as part of our CI system.
Here is my process:
- Call setup script from DOS window: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
- Compile using cl.exe: C:\Users\osqa>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 C:\Users\osqa>cl.exe -version
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9002 : ignoring unknown option '-version'
cl : Command line error D8003 : missing source filename C:\Users\osqa>
C:\Users\osqa>cd workarea\osqa_ca-w10-bld-05_os_211\os C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>cl.exe hello.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved. hello.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved. /out:hello.exe
hello.obj C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>hello.exe
Hello World
This works fine in the DOS window when log into the system using RDP or SSH using OpenSSH.
This also works fine in WSL if I RDP into the VM. But it does not work in WSL if I SSH into the VM: Note that I ssh into the windows VM, call the vcvarsall.bat script and then start WSL and then invoke the compiler. I do not ssh directly into the WSL.
prog\osqa@CA-W10-BLD-05 C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
prog\osqa@CA-W10-BLD-05 C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>cl.exe hello.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
hello.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
hello.obj
prog\osqa@CA-W10-BLD-05 C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>hello.exe
Hello World
prog\osqa@CA-W10-BLD-05 C:\Users\osqa\workarea\osqa_ca-w10-bld-05_os_211\os>wsl
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ rm hello.exe
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ cl.exe --version
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ cl.exe hello.c
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ echo $?
66
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ gcc hello.c
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ echo $?
0
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ ./hello.exe
-bash: ./hello.exe: No such file or directory
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$ ./a.out
Hello World
osqa@ca-w10-bld-05:/c/Users/osqa/workarea/osqa_ca-w10-bld-05_os_211/os$
As one can see cl.exe just returns back with an error '66'.
For shells error 66 typically means: cannot open input.
Environment:
Host machine: Microsoft Windows [Version 10.0.19041.804]
OpenSSH: I've setup OpenSSH using instructions from here: https://video2.skills-academy.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
WSL: Ubuntu 20.04.2 LTS in WSL2. I've also tried WSL1, Ubuntu 18.04 with the same results.
Tests done so far:
I ran the command 'whoami' in DOS window, when logged in through each of RDP and SSH. In both case the results are identical so the user seems to be the same in case of both RDP and SSH.