如何处理 RUST 中未解决的导入 'concrete' 问题

How to deal with unresolved import 'concrete' issues in RUST

我是 RUST 的新手,我正在尝试使用这个具体的库:https://github.com/zama-ai/concrete/tree/master/concrete。我正在尝试在 RUST 中创建一个简单的“Hello World”以查看具体导入是否正确。我按照上述 link.

中的说明进行操作

具体来说,我:

  1. 克隆了 GitHub 存储库。
  2. CD 到具体文件夹 (/concrete/concrete)
  3. 运行"货物新play_with_fhe"
  4. 用新成员“play_with_me”更新了“Cargo.toml”文件
[workspace]

members = [
    "concrete",
    "concrete-npe",
    "concrete-core",
    "concrete-csprng",
    "concrete-commons",
    "concrete-tasks",
    "concrete-boolean",
    "play_with_fhe",
]

[profile.bench]
opt-level = 3
debug = true
lto="fat"

[patch.crates-io]
concrete = {path="concrete"}
concrete-npe = {path="concrete-npe"}
concrete-core = {path="concrete-core"}
concrete-csprng = {path="concrete-csprng"}
concrete-commons = {path="concrete-commons"}
concrete-boolean = {path= "concrete-boolean"}
play_with_fhe = {path= "play_with_fhe"}
  1. Cd 进入“/concrete/concrete/play_with_fhe”并用
  2. 更新“Cargo.toml”文件
[package]
name = "play_with_fhe"
version = "0.1.11"
authors = ["FHE Curious"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
concrete = "^0.1.11"
  1. cd 进入 /concrete/concrete/play_with_fhe_/src 并创建一个 main.rs 文件 运行 一个简单的代码:
use concrete::*;
fn main() {
    println!("Hello, world!");
}
  1. 当我尝试用 rustc main.rs 编译它时,我被告知:
error[E0432]: unresolved import `concrete`
 --> main.rs:2:5
  |
2 | use concrete::*;
  |     ^^^^^^^^ maybe a missing crate `concrete`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.

我该如何解决这个问题?如有任何建议,我们将不胜感激。

由于您正在尝试创建自己的 hello world 项目,因此不需要克隆存储库。您只需要创建一个项目,将具体作为依赖项包含在内,然后将其导入。这些说明在 concrete page(如 Stargateur 注释):

% cargo new play_with_fhe
% cd play_with_fhe

concrete 添加到 Cargo.toml 中的依赖项:

[package]
name = "play_with_fhe"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
concrete = "^0.1"   # <--- This is the only change you make. The rest is template.

然后将 use cargo::* 添加到 main.rs 的顶部并构建它:

% cargo build

这将安装所有内容。有关 Cargo 的更多信息,请参阅 Rust By Example 中的 Dependencies

请注意,除非您使用的是 x86 架构,否则此包可能无法正确构建。例如,it won't run on an Apple M1 without Rosetta2.