【问题标题】:Cargo run ignores the features specified to cargo build货物运行忽略了货物构建指定的功能
【发布时间】:2017-06-08 17:44:54
【问题描述】:

我以这种方式编译了Rust GTK examples

$ cargo build --features gtk_3_10

当我尝试运行示例时,出现错误:

   $ cargo run --bin gtktest   
    Compiling gtk-rs-examples v0.0.1 (file:///home/me123/rust/gtk_examples)
    Finished dev [unoptimized + debuginfo] target(s) in 0.39 secs
     Running `target/debug/gtktest`
This example only work with GTK 3.10 and later
Did you forget to build with `--features gtk_3_10`?

如何解决?

【问题讨论】:

  • 请注意:您不需要在cargo run 之前手动执行cargo buildcargo run 会在需要时自动构建,并传递您提供的相关标志。

标签: rust


【解决方案1】:

调用cargo run时需要传递特征:

cargo run --bin gtktest --features gtk_3_10

您也可以在构建后直接运行可执行文件:

$ cargo build --bin gtktest --features gtk_3_10
$ ./target/debug/gtktest

您可以看出您的命令没有按照您的预期执行,因为输出表明您的代码正在重新编译:

Compiling gtk-rs-examples v0.0.1 (file:///home/me123/rust/gtk_examples)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-24
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-21
    • 2017-02-01
    • 2015-03-17
    相关资源
    最近更新 更多