Unresolved import from imported crates.io crate

I am trying to use the opencv crate with the dnn module. I have compiled opencv with DNN and verified that all the shared libraries exist. If I try to build the following code

use opencv::{

fn main() {
    let a: Vector<i32> = Vector::<i32>::new();
    println!("OPENCV TEST");

I receive the error

error[E0432]: unresolved import `opencv::dnn`
 --> src/main.rs:2:5
2 |     dnn,
  |     ^^^ no `dnn` in the root

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

My Cargo.toml

name = "foobar"
version = "0.1.0"
edition = "2021"

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

opencv = "0.80.0"

At first I thought this issue was somehow related to rust not being able to find some shared library (e.g. libcudnn.so), but (a) that should be a runtime concern, and (b) this error seems to be suggesting that the module itself is not found. I'm a bit unclear on what is going on here, and I think I'm doing something foolish.

I have:

  1. confirmed opencv was built with dnn and that all the libraries exist
  2. the linker path contains the relevant library paths (which still should just be a runtime concern)
  3. the crate does not specify the need to gate the "dnn" module with a feature flag
  4. Cargo.toml specifies rust 2021

If anyone can suggest some debugging tips, that would be helpful. Thanks.

it seems the build script didn't generate rust bindings for the specific module. did you check the output of the crate build script? it should be located at "target/{debug or release}/{crate}-{hash}/output", maybe there's some logging information to help you figure out what's actually happened.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.