Skip to content

dylib crate fails to compile #138339

Closed
Closed
@Dotnet-x86

Description

@Dotnet-x86

I tried this code and run: demo.zip

Code

cargo run dev

Engine

lib.rs

pub fn run () {
    println!("Hello from engine");
}

cargo.toml

[package]
name = "engine"
version = "0.1.0"
edition = "2024"

[dependencies]

[lib]
crate-type = ["dylib"]

Editor

main.rs

extern crate engine;
fn main() {
    engine::run();
    println!("Hello from editor");
}

cargo.toml

[package]
name = "editor"
version = "0.1.0"
edition = "2024"

[dependencies]
engine = {path = "../engine"}

workspace.cargo.toml

[workspace]
resolver = "2"
members = [ "editor","engine"]

I expected the dylib crate to work correctly as a dependency, allowing the binary to dynamically link to it and run without issues.

Instead, this happened:

Details

PS C:\Users\{}\Documents\Rust\development> cargo run dev
   Compiling editor v0.1.0 (C:\Users\compl\Documents\Rust\development\editor)
error: cannot satisfy dependencies so `engine` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
  = note: `engine` was unavailable as a static crate, preventing fully static linking     

error: cannot satisfy dependencies so `core` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `alloc` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `compiler_builtins` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `rustc_std_workspace_core` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `unwind` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `cfg_if` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `hashbrown` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `rustc_std_workspace_alloc` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `std_detect` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `rustc_demangle` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `windows_targets` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: cannot satisfy dependencies so `panic_unwind` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away

error: could not compile `editor` (bin "editor") due to 13 previous errors

Tools

rustc --version --verbose:

rustc 1.87.0-nightly (9fb94b32d 2025-03-10)
binary: rustc
commit-hash: 9fb94b32df38073bf63d009df77ed10cb1c989d0
commit-date: 2025-03-10
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cratesArea: Crates and their interactions (like crate loading)A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.S-has-bisectionStatus: a bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions