twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.88k stars 145 forks source link

issue with opencv while cargo build #498

Closed abdulazeezmpm closed 3 months ago

abdulazeezmpm commented 10 months ago

Get installed llvm and opencv using vcpkg and also add opencv = "0.84.5" in Cargo.toml, then try to run the file I am facing the below error

Getting Error

C:\RUST_PRAC\check>cargo build Compiling opencv v0.84.5 error: failed to run custom build command for opencv v0.84.5

Caused by: process didn't exit successfully: C:\RUST_PRAC\check\target\debug\build\opencv-0107691e4e285377\build-script-build (exit code: 1) --- stdout cargo:rerun-if-env-changed=OPENCV4_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENCV4_STATIC cargo:rerun-if-env-changed=OPENCV4_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=OPENCV4_STATIC cargo:rerun-if-env-changed=OPENCV4_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=OPENCV_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENCV_STATIC cargo:rerun-if-env-changed=OPENCV_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=OPENCV_STATIC cargo:rerun-if-env-changed=OPENCV_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr === Crate version: Some("0.84.5") === Environment configuration: === OPENCV_PACKAGE_NAME = None === OPENCV_PKGCONFIG_NAME = None === OPENCV_CMAKE_NAME = None === OPENCV_CMAKE_BIN = None === OPENCV_VCPKG_NAME = None === OPENCV_LINK_LIBS = None === OPENCV_LINK_PATHS = None === OPENCV_INCLUDE_PATHS = None === OPENCV_DISABLE_PROBES = None === OPENCV_MSVC_CRT = None === CMAKE_PREFIX_PATH = None === OpenCV_DIR = None === PKG_CONFIG_PATH = None === VCPKG_ROOT = None === VCPKGRS_DYNAMIC = None === VCPKGRS_TRIPLET = None === OCVRS_DOCS_GENERATE_DIR = None === DOCS_RS = None === PATH = Some("C:\RUST_PRAC\check\target\debug\deps;C:\RUST_PRAC\check\target\debug;C:\Users\USER\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib;C:\Users\USER\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\RedHat\java-1.8.0-openjdk\missioncontrol\;C:\Program Files\RedHat\java-1.8.0-openjdk\webstart\;C:\Program Files\RedHat\java-1.8.0-openjdk\bin;C:\Program Files\RedHat\java-1.8.0-openjdk\jre\bin;C:\Program Files (x86)\RedHat\java-1.8.0-openjdk\webstart\;C:\Program Files (x86)\RedHat\java-1.8.0-openjdk\bin;C:\Program Files (x86)\RedHat\java-1.8.0-openjdk\jre\bin;C:\Program Files\dotnet\;C:\Program Files\7-Zip;C:\Program Files\Git\cmd;C:\Program Files\LLVM\bin;C:\vcpkg\installed\x64-windows\lib;C:\vcpkg\installed\x64-windows\include;C:\Users\USER\.cargo\bin;C:\Users\USER\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\USER\AppData\Local\Programs\Python\Python37\;C:\Users\USER\AppData\Local\Microsoft\WindowsApps;C:\Users\USER\Downloads\Microsoft VS Code\bin;C:\vcpkg\packages\opencv4_x86-windows;") === Enabled features: === ALPHAMAT === ARUCO === ARUCO_DETECTOR === BARCODE === BGSEGM === BIOINSPIRED === CALIB3D === CCALIB === CUDAARITHM === CUDABGSEGM === CUDACODEC === CUDAFEATURES2D === CUDAFILTERS === CUDAIMGPROC === CUDAOBJDETECT === CUDAOPTFLOW === CUDASTEREO === CUDAWARPING === CVV === DEFAULT === DNN === DNN_SUPERRES === DPM === FACE === FEATURES2D === FLANN === FREETYPE === FUZZY === GAPI === HDF === HFS === HIGHGUI === IMGCODECS === IMGPROC === IMG_HASH === INTENSITY_TRANSFORM === LINE_DESCRIPTOR === MCC === ML === OBJDETECT === OPTFLOW === OVIS === PHASE_UNWRAPPING === PHOTO === PLOT === QUALITY === RAPID === RGBD === SALIENCY === SFM === SHAPE === STEREO === STITCHING === STRUCTURED_LIGHT === SUPERRES === SURFACE_MATCHING === TEXT === TRACKING === VIDEO === VIDEOIO === VIDEOSTAB === VIZ === WECHAT_QRCODE === XFEATURES2D === XIMGPROC === XOBJDETECT === XPHOTO === Detected probe priority based on environment vars: pkg_config: false, cmake: false, vcpkg: true === Probing the OpenCV library in the following order: environment, vcpkg_cmake, vcpkg, pkg_config, cmake === Can't probe using: environment, continuing with other methods because: Some environment variables are missing === Probing OpenCV library using vcpkg_cmake === Discovered vcpkg root: C:\vcpkg === Probing OpenCV library using cmake with toolchain: C:\vcpkg\scripts/buildsystems/vcpkg.cmake === cmake ninja probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts/buildsystems/vcpkg.cmake" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Ninja" === Probing with cmake ninja generator failed, will try Makefile generator, error: program not found === cmake makefiles probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts/buildsystems/vcpkg.cmake" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Unix Makefiles" === Probing with cmake Makefile generator failed, will try deprecated find_package, error: program not found === cmake find-package compile probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts/buildsystems/vcpkg.cmake" "-DCMAKE_BUILD_TYPE=Debug" "--find-package" "-DCOMPILER_ID=GNU" "-DLANGUAGE=CXX" "-DMODE=COMPILE" "-DNAME=OpenCV" === Can't probe using: vcpkg_cmake, continuing with other methods because: program not found === Probing OpenCV library using vcpkg === Can't probe using: vcpkg, continuing with other methods because: Could not find library in Vcpkg tree package opencv4 is not installed for vcpkg triplet x64-windows-static-md, Could not find library in Vcpkg tree package opencv3 is not installed for vcpkg triplet x64-windows-static-md === Probing OpenCV library using pkg_config === Can't probe using: pkg_config, continuing with other methods because: Could not run "pkg-config" "--libs" "--cflags" "opencv4" The pkg-config command could not be found.

Most likely, you need to install a pkg-config package for your OS.

If you've already installed it, ensure the pkg-config command is one of the directories in the PATH environment variable.

If you did not expect this build to link to a pre-installed system library, then check documentation of the opencv crate for an option to build the library from source, or disable features or dependencies that require pkg-config., Could not run "pkg-config" "--libs" "--cflags" "opencv" The pkg-config command could not be found.

Most likely, you need to install a pkg-config package for your OS.

If you've already installed it, ensure the pkg-config command is one of the directories in the PATH environment variable.

If you did not expect this build to link to a pre-installed system library, then check documentation of the opencv crate for an option to build the library from source, or disable features or dependencies that require pkg-config. === Probing OpenCV library using cmake === cmake ninja probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Ninja" === Probing with cmake ninja generator failed, will try Makefile generator, error: program not found === cmake makefiles probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Unix Makefiles" === Probing with cmake Makefile generator failed, will try deprecated find_package, error: program not found === cmake find-package compile probe command: "cmake" "-S" "C:\Users\USER\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.84.5\cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Debug" "--find-package" "-DCOMPILER_ID=GNU" "-DLANGUAGE=CXX" "-DMODE=COMPILE" "-DNAME=OpenCV" === Can't probe using: cmake, continuing with other methods because: program not found Error: "Failed to find installed OpenCV package using probes: environment, vcpkg_cmake, vcpkg, pkg_config, cmake, refer to https://github.com/twistedfall/opencv-rust#getting-opencv for help"

twistedfall commented 9 months ago

vcpkg says that it can't find installed OpenCV:

=== Can't probe using: vcpkg, continuing with other methods because: Could not find library in Vcpkg tree package opencv4 is not installed for vcpkg triplet x64-windows-static-md, Could not find library in Vcpkg tree package opencv3 is not installed for vcpkg triplet x64-windows-static-md

Maybe a triplet mismatch (specify the correct one using env var VCPKGRS_TRIPLET) or a duplicate vcpkg installation (use VCPKG_ROOT env var to specify the proper vcpkg root)?