Closed Necro-U closed 7 months ago
It's difficult to say what exactly goes wrong with your setup, but the crate build script needs a way to find installed OpenCV and if it's installed to a non-standard location without any cmake or pkgconfig files to help it then you'll need to provide the correct paths yourself using the environment variables described here: https://github.com/twistedfall/opencv-rust?tab=readme-ov-file#environment-variables
I want to ask sometinhg about setting environments. I created a config.toml file to set these variables. Will this method work? Or will it set the environments after building?
The environment variables only have effect during build, not in runtime. The build script only reads variables from the environment, so you need a way to transfer these from cargo.toml
to the build script environment. I think cargo can do this for you, but I’ve never tried it myself: https://doc.rust-lang.org/cargo/reference/config.html#env
yes I have tried this but it is not working. Still opencv cannot found. Are there any other suggestions ?
oh wait i tried on the root folder now it works but i have another issue. It complains about clang;
a libclang
shared library is not loaded on this thread.
I am tryingn to build opencv with colcon. But when i try to build it can't find my opencv.
Operating system Pop-os 22.04
Versions Rust : 1.76.0 Opencv : 4.9.0-dev ROS : ROS2 Humble ( I am using r2r
I have installed opencv with package ( apt ) .
The commend:
colcon build --packages-select ehlikesf
And Error:
Starting >>> ehlikesf --- stderr: ehlikesf
warning: profiles for the non root package will be ignored, specify profiles at the workspace root: package: /home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/ground_station/Cargo.toml workspace: /home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/Cargo.toml warning: profiles for the non root package will be ignored, specify profiles at the workspace root: package: /home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/ahrar/Cargo.toml workspace: /home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/Cargo.toml Compiling zenoh-link v0.10.0-rc Compiling opencv v0.86.1 Compiling r2r v0.7.5 error: failed to run custom build command for
opencv v0.86.1
Caused by: process didn't exit successfully:
/home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/target/colcon/build/opencv-cc16ec358b318a6f/build-script-build
(exit status: 101) --- stderr === Crate version: Some("0.86.1") === 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 = Some("/home/hikmetli/Projects/ehlikesf/install/px4_msgs:/opt/ros/humble") === 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("/home/hikmetli/.pyenv/versions/3.9.1/bin:/home/hikmetli/.pyenv/plugins/pyenv-virtualenv/shims:/home/hikmetli/.pyenv/shims:/home/hikmetli/.pyenv/bin:/opt/ros/humble/bin:/home/hikmetli/.pyenv/plugins/pyenv-virtualenv/shims:/home/hikmetli/.pyenv/bin:/opt/gcc-arm-none-eabi-9-2020-q2-update/bin:/home/hikmetli/.cargo/bin:/home/hikmetli/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:~/flutter/bin:/home/hikmetli/.pub-cache/bin:~/flutter/bin:/home/hikmetli/.pub-cache/bin") === Enabled features: === CLANG_RUNTIME === HIGHGUI === IMGCODECS === IMGPROC === VIDEOIO === Detected probe priority based on environment vars: pkg_config: false, cmake: true, vcpkg: false === Probing the OpenCV library in the following order: environment, cmake, pkg_config, vcpkg_cmake, vcpkg === Can't probe using: environment, continuing with other methods because: Some environment variables are missing === Probing OpenCV library using cmake === cmake ninja probe command: cd "/home/hikmetli/Projects/ehlikesf/src/ehli_kesf_calisma_alani/ehlikesf/target/colcon/build/opencv-34127a3c1386513d/out/cmake_probe_build" && "cmake" "-S" "/home/hikmetli/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.86.1/cmake" "-DOCVRS_PACKAGE_NAME=OpenCV" "-DCMAKE_BUILD_TYPE=Release" "-G" "Ninja" === Successfully probed using: cmake === OpenCV library configuration: Library { include_paths: [], version: Version { major: 0, minor: 0, patch: 0, }, cargo_metadata: [ "cargo:rustc-link-search=/usr/local/lib", "cargo:rustc-link-lib=opencv_gapi", "cargo:rustc-link-lib=opencv_stitching", "cargo:rustc-link-lib=opencv_alphamat", "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_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_intensity_transform", "cargo:rustc-link-lib=opencv_line_descriptor", "cargo:rustc-link-lib=opencv_mcc", "cargo:rustc-link-lib=opencv_quality", "cargo:rustc-link-lib=opencv_rapid", "cargo:rustc-link-lib=opencv_reg", "cargo:rustc-link-lib=opencv_rgbd", "cargo:rustc-link-lib=opencv_saliency", "cargo:rustc-link-lib=opencv_signal", "cargo:rustc-link-lib=opencv_stereo", "cargo:rustc-link-lib=opencv_structured_light", "cargo:rustc-link-lib=opencv_superres", "cargo:rustc-link-lib=opencv_surface_matching", "cargo:rustc-link-lib=opencv_tracking", "cargo:rustc-link-lib=opencv_videostab", "cargo:rustc-link-lib=opencv_viz", "cargo:rustc-link-lib=opencv_wechat_qrcode", "cargo:rustc-link-lib=opencv_xfeatures2d", "cargo:rustc-link-lib=opencv_xobjdetect", "cargo:rustc-link-lib=opencv_xphoto", "cargo:rustc-link-lib=opencv_shape", "cargo:rustc-link-lib=opencv_highgui", "cargo:rustc-link-lib=opencv_datasets", "cargo:rustc-link-lib=opencv_plot", "cargo:rustc-link-lib=opencv_text", "cargo:rustc-link-lib=opencv_ml", "cargo:rustc-link-lib=opencv_phase_unwrapping", "cargo:rustc-link-lib=opencv_optflow", "cargo:rustc-link-lib=opencv_ximgproc", "cargo:rustc-link-lib=opencv_video", "cargo:rustc-link-lib=opencv_videoio", "cargo:rustc-link-lib=opencv_imgcodecs", "cargo:rustc-link-lib=opencv_objdetect", "cargo:rustc-link-lib=opencv_calib3d", "cargo:rustc-link-lib=opencv_dnn", "cargo:rustc-link-lib=opencv_features2d", "cargo:rustc-link-lib=opencv_flann", "cargo:rustc-link-lib=opencv_photo", "cargo:rustc-link-lib=opencv_imgproc", "cargo:rustc-link-lib=opencv_core", ], } thread 'main' panicked at /home/hikmetli/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.86.1/build.rs:354:9: Unsupported OpenCV version: 0.0.0, must be from 3.2, 3.4 or 4.x branch note: run withRUST_BACKTRACE=1
environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... gmake[2]: [CMakeFiles/cargo_target.dir/build.make:70: CMakeFiles/cargo_target] Error 101 gmake[1]: [CMakeFiles/Makefile2:164: CMakeFiles/cargo_target.dir/all] Error 2 gmake: *** [Makefile:146: all] Error 2Failed <<< ehlikesf [28.7s, exited with code 2]
Summary: 0 packages finished [29.4s] 1 package failed: ehlikesf 1 package had stderr output: ehlikesf