mtkennerly / shawl

Windows service wrapper for arbitrary commands
MIT License
518 stars 15 forks source link

shawl-v0.6.1-win32.exe binary from releases page does not run on Windows 7 32-bit #10

Closed keithzg closed 3 years ago

keithzg commented 3 years ago

If I try to invoke shawl-v0.6.1-win32.exe on a Windows 7 32-bit test VM, I get confronted with:

Program 'shawl-v0.6.1-win32.exe' failed to execute: This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.

This does not happen if I use the older 0.6.0 binary instead; that runs fine. Oddly enough, it also doesn't happen on a Windows 7 64-bit VM.

Even more intriguingly, if I run cargo build --target i686-pc-windows-msvc --release (when prodding this a bit to figure out if it was something I was just doing weirdly wrong, I noticed I could get complaints about missing vcruntime140.dll, so this seemed like the right target; I have Visual Studio 2019 installed on the Windows 10 system I compiled this on), the resulting binary does run fine on my Windows 7 32-bit test system.

I hope that's enough details to track down what the problem is! I'm also very willing to try any additional debugging steps, or provide any additional information, if such is necessary :)

Enet4 commented 3 years ago

I cannot provide any insights regarding the 32-bit executables (all of my uses of Shawl are on 64-bit machines), but the part about the missing vcruntime140.dll is a common one. By default, executables built for Windows require this Visual C runtime library. One known way to overcome this is to instruct the compiler to statically link this runtime.

RUSTFLAGS='-C target-feature=+crt-static' cargo build --target i686-pc-windows-msvc --release

Otherwise, the dll can either be included as a sibling to the executable, or one can require all machines to install the Visual C++ runtime redistributable (2015-2019 should do the trick).

keithzg commented 3 years ago

Oh, interesting to know about the option to static link! Not a problem at all for my own current use however; using Shawl for a work project where we're adding the option to run an existing program of ours as a service, and it seemed nicer to use an existing wrapper than try and reinvent the wheel, and since our software is already compiled using the Microsoft C++ compiler we're already redistributing all the necessary DLLs with our executables anyways. (Blows my mind every time I consider that Microsoft's official development tools for Windows require you to redistribute some of their DLLs because Windows doesn't ship with 'em, but oh well!)

It's also not a big deal for me that the official download doesn't work on 32-bit Windows 7 (I have yet to check any other 32-bit Windows versions, as very few of our clients run 32-bit installs of more recent Windows versions) since as mentioned above I am able to compile my own copy fairly trivially. However it does seem bad that the download on the releases page doesn't work properly, especially for any folks who don't realize how easy it can be to compile a well-setup Rust project like this one!

mtkennerly commented 3 years ago

Thanks for pointing this out! 0.6.1 was the first release where I used builds from a GitHub workflow, so I'll try to figure out what went wrong. And I'll go ahead and statically link the CRT to simplify that (I've been doing that in another project without any issues).

mtkennerly commented 3 years ago

I think it's fixed now. Could you try this on your 32-bit system? I used to have access to one for testing, but don't at the moment.

shawl-v0.6.1-post.2+10dd09c-win32.zip

This also includes the static linking change.

keithzg commented 3 years ago

Works like a charm!

image

I can confirm that this version not only no longer gives the system-incompatibility warning, it now also appears to have no need for the MSVC DLLs.

mtkennerly commented 3 years ago

Thanks for verifying! I've just released v0.6.2 with these changes \:D