1

I am targeting my Rust project for Windows and Linux.

On Windows, the code needs to be linked to an executable, whereas on Linux - as a shared library.

To link the project as a Linux shared library, I added the following section to Cargo.toml:

[lib]
name = "my_project_name"
crate-type = ["cdylib"]

However that results in shared library generated on Windows, too.

Is there a way to tell Rust compiler to link the project as executable on Windows and as a library on Linux?

user2551017
  • 153
  • 10
  • 1
    I think it not possible, but you may try to build the binary and the library for both platforms, then using the required ones – Kitsu Jun 29 '20 at 14:34

1 Answers1

1

As far as I can see it's not possible to do so right now. Closest information I could find was this for a similar use case.

ShadowMitia
  • 2,411
  • 1
  • 19
  • 24