title: Generating Rust executable or library, depending on the target platform
body: <p>I am targeting my Rust project for Windows and Linux.</p>
  <p>On Windows, the code needs to be linked to an executable, whereas on Linux - as a shared library.</p>
  <p>To link the project as a Linux shared library, I added the following section to <code>Cargo.toml</code>:</p>
  <pre><code>[lib]
  name = &quot;my_project_name&quot;
  crate-type = [&quot;cdylib&quot;]
  </code></pre>
  <p>However that results in shared library generated on Windows, too.</p>
  <p>Is there a way to tell Rust compiler to link the project as executable on Windows and as a library on Linux?</p>