I'm encountering a frustrating issue while trying to build my Rust project that uses a dynamic library (dylib
). I keep getting the error message: 'cannot satisfy dependencies so engine
only shows up once', and 'engine was unavailable as a static crate, preventing fully static linking'.
Engine
Cargo.toml
[package]
name = "engine"
version = "0.1.0"
edition = "2024"
[dependencies]
mlua = {version = "*", features = ["lua54", "vendored"]}
[lib]
crate-type = ["dylib"]
lib.rs
use mlua::*;
use std::fs;
use std::env;
pub fn run() -> Result<()> {
let exe_path = env::current_exe().expect("Failed to get current exe path");
let exe_dir = exe_path.parent().expect("Failed to get exe directory");
let lua_path = exe_dir.join("main.lua"); // ไฟล์ main.lua
let lua_code = fs::read_to_string(&lua_path)
.expect("Failed to read main.lua");
let lua = Lua::new();
lua.load(&lua_code).exec()?;
println!("Hello from engine");
Ok(())
}
Editor
Cargo.toml
[package]
name = "editor"
version = "0.1.0"
edition = "2024"
[dependencies]
engine = {path = "../engine"}
main.rs
use engine::run;
fn main() {
match run() {
Ok(_) => println!("Parsing successful!"),
Err(e) => eprintln!("Parsing error: {}", e),
}
println!("Hello from editor!");
}
Output
PS C:\Users\{}\Documents\Rust\Demo> cargo run dev
Compiling engine v0.1.0 (C:\Users\compl\Documents\Rust\Demo\engine)
Compiling editor v0.1.0 (C:\Users\compl\Documents\Rust\Demo\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 `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 `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 `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