Ko32mo
Ko32mo

Reputation: 127

Cargo run ignores the features specified to cargo build

I've compiled the Rust GTK examples this way:

$ cargo build --features gtk_3_10

When I try to run the example, an error occurs:

   $ 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`?

How to fix that?

Upvotes: 1

Views: 805

Answers (1)

Shepmaster
Shepmaster

Reputation: 430310

You need to pass the features when calling cargo run:

cargo run --bin gtktest --features gtk_3_10

You could also run the executable directly after building it:

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

You can tell that your command isn't doing what you expect because the output says that your code is being recompiled:

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

Upvotes: 1

Related Questions