Rust error: a bin target must be available for `cargo run`
In this post, we will learn how to fix the rust build error a bin target must be available for `cargo run`.
In my case I was getting this error because while creating rust project with command cargo new project_name, the source (src) directory was not containing main.rs but it was containing lib.rs because cargo new project_name command was creating library not binary project. You can solve above issue by creating project with below command.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
In this post, we will learn how to fix the rust build error a bin target must be available for `cargo run`.
In my case I was getting this error because while creating rust project with command cargo new project_name, the source (src) directory was not containing main.rs but it was containing lib.rs because cargo new project_name command was creating library not binary project. You can solve above issue by creating project with below command.
cargo new project_name --bin
Above command will create your project with directory structure /project_name
- Cargo.toml
- src/main.rs
Now you can build and run project with cargo build
cargo run
Comments
Post a Comment