Entry symbol `main` declared multiple times
⚓ Rust 📅 2025-05-23 👤 surdeus 👁️ 10Hello,
I am trying to mix a lib.rs and main.rs files inside the same project.
cargo.toml
[package]
name = "lib_main"
version = "0.1.0"
edition = "2021"
[lib]
name = "lib"
path = "src/lib.rs"
crate-type = ["staticlib", "cdylib"]
lib.rs
#[no_mangle]
pub fn main() {
println!("{}", "hello lib");
}
main.rs
#[path = "lib.rs"]
mod this;
fn main() {
this::main();
}
Is it possible ?
Thank you in advance for your help.
4 posts - 3 participants
🏷️ rust_feed