【发布时间】:2018-11-04 18:04:07
【问题描述】:
我有多工作区 Cargo 项目。它有两个工作区,common 和 server。 common 是 lib 项目,服务器是 bin 项目。
项目在Github的位置是here.
下面是项目结构。
.
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── README.md
└── server
├── Cargo.toml
└── src
└── main.rs
4 directories, 6 files
./Cargo.toml 文件的文件内容是
[package]
name = "multi_module_cargo_project"
version = "0.1.0"
authors = ["rajkumar"]
[workspace]
members = ["common", "server"]
[dependencies]
当我运行命令cargo build --all:
error: failed to parse manifest at `/home/rajkumar/Coding/Rust/ProgrammingRust/multi_module_cargo_project/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
所以我在Cargo.toml 中添加了以下内容,但仍然无法构建项目。
[[bin]]
name = "server/src/main.rs"
如何构建项目。我错过了什么?
【问题讨论】:
-
我认为您应该只将
[workspace]放在根清单中,因此删除[package]和[dependencies],只将其放在server和common内的清单中。 -
@Stargateur - 你是对的。这样可行。如果你回答了这个问题,我会接受你的回答。
标签: rust rust-cargo