【问题标题】:How to compile rusqlite 0.20.0 with cargo如何用 cargo 编译 rusqlite 0.20.0
【发布时间】:2019-10-17 03:57:53
【问题描述】:

我正在尝试在我的 rust 项目中添加 sqlite 支持。 I found rusqlite on crates.io. 我在 Cargo.toml 中添加了版本行。我添加了一些在rusqlite docs page 上找到的导入(未使用)。运行 car go build 后,我恢复了一个错误。

我还没有实现任何东西。我只是想添加和编译依赖项。 main.rs:

extern crate rusqlite;

use rusqlite::{Connection, Result};
use rusqlite::NO_PARAMS;

Cargo.toml:

[package]
name = "program"
version = "0.1.0"
authors = ["97"]

[dependencies]
argparse = "0.2.2"
rand = "0.4.0"
rusqlite = "0.20.0"

收到错误:

$ cargo build
   Compiling pkg-config v0.3.16
   Compiling fallible-iterator v0.2.0
   Compiling memchr v2.2.1
   Compiling bitflags v1.2.1
   Compiling lru-cache v0.1.2
error[E0432]: unresolved import `std::ops::Bound`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:72:16
   |
72 | use std::ops::{Bound, RangeBounds};
   |                ^^^^^ no `Bound` in `ops`

error[E0432]: unresolved import `std::ops::RangeBounds`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:72:23
   |
72 | use std::ops::{Bound, RangeBounds};
   |                       ^^^^^^^^^^^ no `RangeBounds` in `ops`

error[E0658]: `dyn Trait` syntax is unstable (see issue #44662)
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.16/src/lib.rs:143:32
    |
143 |     fn cause(&self) -> Option<&dyn error::Error> {
    |                                ^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

error: Could not compile `pkg-config`.
warning: build failed, waiting for other jobs to finish...
error[E0658]: `crate` in paths is experimental (see issue #45477)
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/fallible-iterator-0.2.0/src/lib.rs:98:5
   |
98 | use crate::imports::*;
   |     ^^^^^

error[E0658]: `dyn Trait` syntax is unstable (see issue #44662)
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/fallible-iterator-0.2.0/src/lib.rs:2606:24
     |
2606 | fn _is_object_safe(_: &dyn DoubleEndedFallibleIterator<Item = (), Error = ()>) {}
     |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `fallible-iterator`.
warning: build failed, waiting for other jobs to finish...
error: build failed

编辑

货物 0.26.0 (41480f5cc 2018-02-26)

rustc 1.25.0 (84203cac6 2018-03-25)

【问题讨论】:

  • 您是否正在运行旧版本的 Rust?你最近更新了吗? Bound 被添加到 1.17.0 和 RangeBounds 中 1.28.0。
  • @loganfsmyth cargo --version [RET] cargo 0.26.0 (41480f5cc 2018-02-26)
  • @loganfsmyth(抱歉。忘记 cargo 和 rustc 不一样。) rustc 1.25.0 (84203cac6 2018-03-25)。那么它必须是RangeBounds。你知道 rust 1.25 支持哪个版本的 rusqlite 吗?
  • 我不知道,也不能保证有一个。你能更新吗?从那天开始,您可以看到,您的版本落后了一年半以上。
  • @loganfsmyth 我可能会更新。再次运行rustup,对吗?

标签: sqlite rust


【解决方案1】:

大多数 crate 只支持最新的 Rust 版本。您可以尝试使用旧版本的 crate,但最简单的方法是将 Rust 更新到当前支持的版本。

如果您使用的是 Linux 发行版中的 Rust,请将其卸载,然后从 https://rustup.rs 获取它,这样可以使其保持最新状态。 Rust 生态系统的发展速度比大多数发行版都要快。

运行rustup update。

【讨论】:

    猜你喜欢
    • 2015-12-13
    • 2022-01-20
    • 2022-09-25
    • 1970-01-01
    • 2015-02-22
    • 2022-09-13
    • 2021-07-16
    • 2022-11-10
    • 1970-01-01
    相关资源
    最近更新 更多