immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.81k stars 220 forks source link

error running cargo install c2rust on Windows 11 #971

Closed MurraySobol closed 1 year ago

MurraySobol commented 1 year ago

When I run "cargo install c2rust" on my Windows 11 64-bit laptop I get the following errors: Compiling c2rust-build-paths v0.18.0 err

or[E0433]: failed to resolve: could not find unix in os --> C:\Users\murra.cargo\registry\src\index.crates.io-6f17d22bba15001f\c2rust-build-paths-0.18.0\src\lib.rs:35:26 | 35 | use std::os::unix::ffi::OsStrExt; | ^^^^ could not find unix in os

Compiling env_logger v0.10.0 error[E0599]: no function or associated item named from_bytes found for struct OsStr in the current scope --> C:\Users\murra.cargo\registry\src\index.crates.io-6f17d22bba15001f\c2rust-build-paths-0.18.0\src\lib.rs:37:20 | 37 | OsStr::from_bytes(path) | ^^^^^^^^^^ function or associated item not found in OsStr

Can someone PLEASE fix these errors, I KNOW that running on Windows is not you first or highest priorities but these errors (to me) are SO ELEMENTARY that the SHOULD be fixed, regardless of the O/S clients are running on. I don't believe that the "fix" for this issue is that convoluted or complex, I just don't think any appreciation is being given to this problem. IMO, it is simply BAD FORM to reference specific O/S's (such as 'unix') when functions ALREADY EXIST to identify the O/S and take the appropriate action. In MY case, I have a proposed task to rewrite some Windows DLLs into rust code, for the obvious reasons of improved safety and the other benefits that rust provides.

Thanks for listening to my coments.

Murray

thedataking commented 1 year ago

Hi Murray, thanks for the report.

The issues you ran into may seem elementary but they would in all likelihood surface many more issues that would need to be resolved in order to support Windows natively. For instance, we'd need a way to generate compile commands on Windows, we'd need to make sure we handle MSVC-specific extensions, and many more issues that I'm not even aware of.

You write that you're running Windows 11 on a 64-bit laptop so in all likelihood you'll be able to successfully compile c2rust if you enable Windows Subsystem for Linux (WSL). Of course that will not let you transpile C code written for Windows – so I realize that WSL might not be a viable workaround for your situation.

kkysen commented 8 months ago

Hi @MurraySobol, that above error (#708) was just fixed by #1036, though there are still much deeper issues with Windows. Just wanted to let you know that that trivial error has at least been fixed now.