opencv-rust icon indicating copy to clipboard operation
opencv-rust copied to clipboard

Building project in compiling opencv-binding-generator fails-Can't get kind of parent for cpp namespace

Open SULAPIS opened this issue 2 years ago • 4 comments

So i run choco install llvm opencv and then set OPENCV_LINK_LIBS, OPENCV_LINK_PATHS and OPENCV_INCLUDE_PATHS. When i run cargo build, the thread 'main' panicked at internal error, maybe I used the OpenCV API incorrectly, but my code is like this:

use opencv::prelude::*;

fn main() {}

When I use the example code, it also panicked at same error. I don't know what to do.

  1. Operating system: Windows 11
  2. The way you installed OpenCV: Installed via Chocolatey (choco install llvm opencv) with environment variables added manually.
  3. OpenCV version: 4.5.5
  4. rustc version: rustc 1.63.0
  5. Attach the full output of the following command from your project directory: error.txt

SULAPIS avatar Sep 08 '22 15:09 SULAPIS

the same error

imxood avatar Sep 18 '22 14:09 imxood

I was able to fix this by downgrading LLVM to version 14. I guess LLVM 15 is not supported right now.

aliu avatar Sep 19 '22 03:09 aliu

I also downgraded to LLVM 14 from 15, but then I got some linker error. Was using vcpkg opencv before switching to chocolatey, but same linking error.

ramidzkh avatar Sep 19 '22 06:09 ramidzkh

That's a great clue, I'll investigate, thank you!

twistedfall avatar Sep 19 '22 07:09 twistedfall

I met the same problem. Then, I downgrade to llvm14, but get compile error:

    fatal error: 'opencv2/videoio/registry.hpp' file not found

The error is casued by opencv-0.68.0/src_cpp/videoio.hpp, which says:

#if !(CV_VERSION_MAJOR == 3 && CV_VERSION_MINOR == 2)
	#include <opencv2/videoio/registry.hpp>
#endif

Then I checked the definition of CV_VERSION_MAJOR and CV_VERSION_MINOR, which is fixed set as:

pub const CV_VERSION: &str = "4.6.0";
pub const CV_VERSION_MAJOR: i32 = 4;
pub const CV_VERSION_MINOR: i32 = 6;

// Maybe somewhere else change the value, but I didn't realize.

Considering the problem may caused by version, I download the source code of opencv4.6 and compile it, then all things work.

Hope this info helps.

  1. Operating system: Liunx RHEL x86_64
  2. The way you installed OpenCV: Manually compile with cmake and export for pkgconfig.
  3. OpenCV version: 3.4.0
  4. Attach the full output of the following command from your project directory:

output.txt

bingxinliu avatar Sep 29 '22 08:09 bingxinliu

Thanks for all of the reports! This issue have been fixed in the latest release of the opencv-binding-generator crate, just doing a cargo update in the project directory should pull the fixed version (0.47.1).

twistedfall avatar Oct 01 '22 06:10 twistedfall