Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Multiple files, multiple binaries and a library?
Hello,
I have a project with the following structure.
├── src
│ ├── algorithms
│ │ ├── file1.rs
│ │ ├── file2.rs
│ ├── bin
│ │ ├── main1.rs
│ │ ├── main2.rs
│ ├── lib.rs
On lib.rs:
pub mod algorithms {
pub mod file1;
pub mod file2;
}
On main1.rs:
use algorithms::file1::fnc1;
Cargo.toml:
[[bin]]
name = "main1"
path = "src/bin/main1.rs"
[[bin]]
name = "main2"
path = "src/bin/main2.rs"
Now, I want to create a library from that. So I added the following to my Cargo.toml:
[lib]
name = "mylib"
crate-type = ["cdylib"]
And now the "use" on main files cannot find the internal files.
How can I solve it? Te goal is to allow something like it to work:
cargo build --bin main1
cargo build --lib
4 posts - 2 participants
🏷️ Rust_feed