Cargo OS Conditional Dependencies

I'm working on a library in which the API implementation is completely separate for Windows and Linux.

Unfortunately, the Linux implementation has crate dependencies which are broken on windows, but cargo refuses to continue the compilation on windows even though the crates are not used.

Is there a way to make cargo require different crates depending on OS?

Yes, as stated in the Cargo Manifest documentation.

Ah, yes somehow I missed the blurb detailing this exact scenario.


1 Like

Here is a more direct to specifying platform specific dependencies in the Cargo documentation.