Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "Failed to find OpenCV package using probes: environment, pkg_config, cmake, vcpkg_cmake, vcpkg" #402

Closed
Tramac opened this issue Dec 16, 2022 · 4 comments

Comments

@Tramac
Copy link

Tramac commented Dec 16, 2022

  1. Operating system: Ubuntu 18.04
  2. The way you installed OpenCV: sudo apt install libopencv-dev clang libclang-dev
  3. OpenCV version: 3.2.0
  4. rustc version : rustc 1.65.0 (897e37553 2022-11-02)
  5. Attach the full output of the following command from your project directory:
    RUST_BACKTRACE=full cargo build -vv 

The err info:

Caused by:
  process didn't exit successfully: `/target/debug/build/opencv-b46d4ab21d0f0635/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=OPENCV4_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  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=TARGET_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=TARGET_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=TARGET_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=TARGET_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_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  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=TARGET_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_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_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=TARGET_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=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  === Crate version: Some("0.63.2")
  === 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
  ===   CMAKE_PREFIX_PATH = None
  ===   OpenCV_DIR = None
  ===   PKG_CONFIG_PATH = None
  ===   VCPKG_ROOT = None
  ===   VCPKGRS_DYNAMIC = None
  === Enabled features:
  ===   IMGPROC
  === 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
  === Can't probe using: pkg_config, continuing with other methods because: `"pkg-config" "--libs" "--cflags" "opencv4"` did not exit successfully: exit status: 1
  error: could not find system library 'opencv4' required by the 'opencv' crate

  --- stderr
  Package opencv4 was not found in the pkg-config search path.
  Perhaps you should add the directory containing `opencv4.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'opencv4' found
  , `"pkg-config" "--libs" "--cflags" "opencv"` did not exit successfully: exit status: 1
  error: could not find system library 'opencv' required by the 'opencv' crate

  --- stderr
  Package opencv was not found in the pkg-config search path.
  Perhaps you should add the directory containing `opencv.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'opencv' found

  === Probing OpenCV library using cmake
  === cmake ninja probe command: "cmake" "-S" "/cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/opencv-0.63.2/cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Ninja"
  === Probing with cmake ninja generator failed, will try Makefile generator, error: cmake returned an error
      stdout: "-- Configuring incomplete, errors occurred!\nSee also \"/target/aarch64-unknown-linux-gnu/debug/build/opencv-35a641caf5ba601e/out/cmake_probe_build/CMakeFiles/CMakeOutput.log\".\n"
      stderr: "CMake Error: CMake was unable to find a build program corresponding to \"Ninja\".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.\nCMake Error: CMAKE_C_COMPILER not set, after EnableLanguage\nCMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage\n"
  === cmake makefiles probe command: "cmake" "-S" "/cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/opencv-0.63.2/cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Debug" "-G" "Unix Makefiles"
  === Probing with cmake Makefile generator failed, will try deprecated find_package, error: cmake returned an error
      stdout: "-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc - works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ - works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Configuring incomplete, errors occurred!\nSee also \"/target/aarch64-unknown-linux-gnu/debug/build/opencv-35a641caf5ba601e/out/cmake_probe_build/CMakeFiles/CMakeOutput.log\".\n"
      stderr: "CMake Error at CMakeLists.txt:5 (find_package):\n  By not providing \"FindOpenCV.cmake\" in CMAKE_MODULE_PATH this project has\n  asked CMake to find a package configuration file provided by \"OpenCV\", but\n  CMake did not find one.\n\n  Could not find a package configuration file provided by \"OpenCV\" with any\n  of the following names:\n\n    OpenCVConfig.cmake\n    opencv-config.cmake\n\n  Add the installation prefix of \"OpenCV\" to CMAKE_PREFIX_PATH or set\n  \"OpenCV_DIR\" to a directory containing one of the above files.  If \"OpenCV\"\n  provides a separate development package or SDK, be sure it has been\n  installed.\n\n\n"
  === cmake find-package compile probe command: "cmake" "-S" "/cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/opencv-0.63.2/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: cmake returned an error
      stdout: "OpenCV not found.\n"
      stderr: "CMake Error: Problem processing arguments. Aborting.\n\n"
  === Probing OpenCV library using vcpkg_cmake
  === Can't probe using: vcpkg_cmake, continuing with other methods because: Could not find Vcpkg tree: No vcpkg installation found. Set the VCPKG_ROOT environment variable or run 'vcpkg integrate install'
  === Probing OpenCV library using vcpkg
  === Can't probe using: vcpkg, continuing with other methods because: the vcpkg-rs Vcpkg build helper can only find libraries built for the MSVC ABI., the vcpkg-rs Vcpkg build helper can only find libraries built for the MSVC ABI.
Error: "Failed to find OpenCV package using probes: environment, pkg_config, cmake, vcpkg_cmake, vcpkg"
Makefile:12: recipe for target 'build' failed

I have seen a lot of environment configurations setting about OPENCV_LINK_LIBS ,OPENCV_LINK_PATHS and OPENCV_INCLUDE_PATHS with Windows, but not ubuntu, how should the ubuntu system set ?

@Tramac
Copy link
Author

Tramac commented Dec 16, 2022

I have set: export OPENCV_INCLUDE_PATHS=/usr/include/opencv2, but there is same error. I don't known what OPENCV_LINK_LIBS and OPENCV_LINK_PATHS should be set to.

@ninetynin
Copy link

I have set: export OPENCV_INCLUDE_PATHS=/usr/include/opencv2, but there is same error. I don't known what OPENCV_LINK_LIBS and OPENCV_LINK_PATHS should be set to.

Did u find any solution? Im facing the same issue

@twistedfall
Copy link
Owner

I've just tested the blank docker image of Ubuntu 18.04, after installing the listed requirements (apt install libopencv-dev clang libclang-dev) the build succeeded without any additional setup, so I'm not exactly sure what's specifically going wrong with your attempt. In any case if the automatic detection fails you can always do that manually by setting up OPENCV_INCLUDE_PATHS, OPENCV_LINK_LIBS and OPENCV_LINK_PATHS (you need to set up all 3 of them). Please check the readme for some instructions on how to set it up, but for a default Ubuntu 18.04 they need to be as follows:

export OPENCV_INCLUDE_PATHS="/usr/include/"
export OPENCV_LINK_PATHS="/usr/lib/x86_64-linux-gnu/"
export OPENCV_LINK_LIBS="opencv_core,opencv_imgproc"

The particular set of OPENCV_LINK_LIBS depends on which OpenCV features you're using, so YMMV.

@twistedfall
Copy link
Owner

Although I must note that I'm planning to phase away support for OpenCV 3.2, it's too old and not maintained any more by the upstream.

@Tramac Tramac closed this as completed Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants