1

I've added new amiquip dependency in the cargo.toml

[package]
name = "sender"
version = "0.1.0"
edition = "2021"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
    "derive",
] }
amiquip = { version = "0.4", default-features = false, optional = true }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }


[dev-dependencies]
sp-core = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }
sp-io = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }
sp-runtime = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.32" }


[features]
default = ["std"]
std = ["codec/std", "frame-benchmarking?/std",
"amiquip",
 "frame-support/std", 
 "frame-system/std",
  "scale-info/std"]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
try-runtime = ["frame-support/try-runtime"]

But it still showing me this error use of "undeclared crate or module amiquip". I've also tried extern crate amiquip. But it didn't work.

enter image description here

1 Answer 1

1

This is intended behavior.

Two major points to notice

1. It's optional dependency

amiquip = { version = "0.4", default-features = false, optional = true }

2. It's will be part of target only when std feature is enabled

[features]
default = ["std"]
std = ["codec/std", "frame-benchmarking?/std",
 "amiquip",
 "frame-support/std", 
 "frame-system/std",
 "scale-info/std"]

What you actually need to do is something like

    #[cfg(feature = "std")]
    use amiquip;

Please adjust your features and dependent features wisely.

For more on cargo features refer https://doc.rust-lang.org/cargo/reference/features.html

Hope it helps! 😊

3
  • Sorry .It Didn't Work May 22, 2023 at 4:33
  • Do you have code where you can reproduce it?
    – Arjun
    May 22, 2023 at 14:48
  • may be on github
    – Arjun
    May 22, 2023 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.