ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
173 stars 82 forks source link

Static CRT option for Windows #69

Closed pravic closed 3 years ago

pravic commented 3 years ago

It would be nice if this crate allowed to link C runtime library statically, as a cargo feature option (say, windows-static-crt).

https://github.com/ruabmbua/hidapi-rs/blob/06354516eb65a65319748c28ea622b3eb324005a/build.rs#L115-L121

needs to be modified to include a call to static_crt(true)

See https://docs.rs/cc/1.0.67/cc/struct.Build.html#method.static_crt

ruabmbua commented 3 years ago

Is it a good idea, to link the crt statically? According to my windows knowledge (which might be horribly / out of date), the syscall numbers etc... are very unstable in the windows kernel. The crt is probably using some, so it might cause incompatibilities?

Of course, I would gladly review a PR, if you have the time to create one.

pravic commented 3 years ago

It has nothing to do with syscalls - CRT on Windows is about C runtime. Syscalls are managed by NTDLL. So, it's different from Linux world where syscalls are managed by libc (however, even there there is musl).

This is an issue on newly installed windows machines, since Microsoft does not by default supply C runtime DLLs with windows/windows update, and lots of software opts to statically link those runtimes.

So, basically we will give an option to choose between linking statically or dynamically.

pravic commented 3 years ago

As for the PR - okay, I'll make one.