opencv-rust
opencv-rust copied to clipboard
A simple program to turn on the camera successfully cargo build, but cargo build the following code reports an error
/home/cat/rust/cam# cargo build
Compiling opencv v0.88.5
error: failed to run custom build command for `opencv v0.88.5`
Caused by:
process didn't exit successfully: `/home/cat/rust/cam/target/debug/build/opencv-4e2cc385db21c73c/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=OPENCV4_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=SYSROOT
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu
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_aarch64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rustc-cfg=ocvrs_opencv_branch_4
cargo:rerun-if-env-changed=OPENCV_PACKAGE_NAME
cargo:rerun-if-env-changed=OPENCV_PKGCONFIG_NAME
cargo:rerun-if-env-changed=OPENCV_CMAKE_NAME
cargo:rerun-if-env-changed=OPENCV_CMAKE_BIN
cargo:rerun-if-env-changed=OPENCV_VCPKG_NAME
cargo:rerun-if-env-changed=OPENCV_LINK_LIBS
cargo:rerun-if-env-changed=OPENCV_LINK_PATHS
cargo:rerun-if-env-changed=OPENCV_INCLUDE_PATHS
cargo:rerun-if-env-changed=OPENCV_DISABLE_PROBES
cargo:rerun-if-env-changed=OPENCV_MSVC_CRT
cargo:rerun-if-env-changed=CMAKE_PREFIX_PATH
cargo:rerun-if-env-changed=OpenCV_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=VCPKG_ROOT
cargo:rerun-if-env-changed=VCPKGRS_DYNAMIC
cargo:rerun-if-env-changed=VCPKGRS_TRIPLET
cargo:rerun-if-env-changed=OCVRS_DOCS_GENERATE_DIR
cargo:rerun-if-env-changed=DOCS_RS
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/ocvrs_common.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/hdf.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/xfeatures2d.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/videoio.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/face.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/core.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/sfm.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/photo.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/aruco.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/manual-core.cpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/ccalib.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/dnn.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/alphamat.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/bioinspired.hpp
cargo:rerun-if-changed=/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.5/src_cpp/gapi.hpp
cargo:rerun-if-changed=Cargo.toml
--- stderr
=== Crate version: Some("0.88.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("/root/.cargo/bin:/opt/ros/galactic/bin:/root/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin")
=== 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: false
=== Probing the OpenCV library in the following order: environment, pkg_config, cmake, vcpkg_cmake, vcpkg
=== Can't probe using: environment, continuing with other methods because: Some environment variables are missing
=== Probing OpenCV library using pkg_config
=== Successfully probed using: pkg_config
=== OpenCV library configuration: Library {
include_paths: [
"/usr/include/opencv4/opencv",
"/usr/include/opencv4",
],
version: Version {
major: 4,
minor: 2,
patch: 0,
},
cargo_metadata: [
"cargo:rustc-link-search=/usr/lib/aarch64-linux-gnu",
"cargo:rustc-link-lib=opencv_stitching",
"cargo:rustc-link-lib=opencv_aruco",
"cargo:rustc-link-lib=opencv_bgsegm",
"cargo:rustc-link-lib=opencv_bioinspired",
"cargo:rustc-link-lib=opencv_ccalib",
"cargo:rustc-link-lib=opencv_dnn_objdetect",
"cargo:rustc-link-lib=opencv_dnn_superres",
"cargo:rustc-link-lib=opencv_dpm",
"cargo:rustc-link-lib=opencv_highgui",
"cargo:rustc-link-lib=opencv_face",
"cargo:rustc-link-lib=opencv_freetype",
"cargo:rustc-link-lib=opencv_fuzzy",
"cargo:rustc-link-lib=opencv_hdf",
"cargo:rustc-link-lib=opencv_hfs",
"cargo:rustc-link-lib=opencv_img_hash",
"cargo:rustc-link-lib=opencv_line_descriptor",
"cargo:rustc-link-lib=opencv_quality",
"cargo:rustc-link-lib=opencv_reg",
"cargo:rustc-link-lib=opencv_rgbd",
"cargo:rustc-link-lib=opencv_saliency",
"cargo:rustc-link-lib=opencv_shape",
"cargo:rustc-link-lib=opencv_stereo",
"cargo:rustc-link-lib=opencv_structured_light",
"cargo:rustc-link-lib=opencv_phase_unwrapping",
"cargo:rustc-link-lib=opencv_superres",
"cargo:rustc-link-lib=opencv_optflow",
"cargo:rustc-link-lib=opencv_surface_matching",
"cargo:rustc-link-lib=opencv_tracking",
"cargo:rustc-link-lib=opencv_datasets",
"cargo:rustc-link-lib=opencv_text",
"cargo:rustc-link-lib=opencv_dnn",
"cargo:rustc-link-lib=opencv_plot",
"cargo:rustc-link-lib=opencv_ml",
"cargo:rustc-link-lib=opencv_videostab",
"cargo:rustc-link-lib=opencv_videoio",
"cargo:rustc-link-lib=opencv_viz",
"cargo:rustc-link-lib=opencv_ximgproc",
"cargo:rustc-link-lib=opencv_video",
"cargo:rustc-link-lib=opencv_xobjdetect",
"cargo:rustc-link-lib=opencv_objdetect",
"cargo:rustc-link-lib=opencv_calib3d",
"cargo:rustc-link-lib=opencv_imgcodecs",
"cargo:rustc-link-lib=opencv_features2d",
"cargo:rustc-link-lib=opencv_flann",
"cargo:rustc-link-lib=opencv_xphoto",
"cargo:rustc-link-lib=opencv_photo",
"cargo:rustc-link-lib=opencv_imgproc",
"cargo:rustc-link-lib=opencv_core",
],
}
=== Detected OpenCV module header dir at: /usr/include/opencv4/opencv2
=== Found OpenCV version: 4.2.0 in headers located at: /usr/include/opencv4
=== Generating code in: /home/cat/rust/cam/target/debug/build/opencv-deac5a84212ef75a/out
=== Placing generated bindings into: /home/cat/rust/cam/target/debug/build/opencv-deac5a84212ef75a/out/opencv
=== Using OpenCV headers from: /usr/include/opencv4
=== Cannot canonicalize one of the additional_include_dirs: /usr/include/opencv4/opencv, reason: No such file or directory (os error 2)
thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clang-sys-1.6.1/src/lib.rs:1735:1:
a `libclang` shared library is not loaded on this thread
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Please refer to the item 8 in https://github.com/twistedfall/opencv-rust#troubleshooting
Actually it's number 9, not 8
I belive I encountered an identical error and enabling the clang-runtime
feature fixed it for me.
Setting PKG_CONFIG_PATH
which is what I believe @twistedfall is referring to didn't help.
[dependencies] opencv = { version = "0.88.5", features = ["clang-runtime"] }
@Skgland Thanks for the help, yeah, I was actually referring to the item 9
@xiaocijun Can you share the full list of the dependencies from you Cargo.toml
? It can happen that some dependencies pull clang
with clang-runtime
and some without it, then it would be more difficult to get it running