The opencv crate requires the OpenCV system library to be present. Depending on your distribution, use the following commands to install the necessary packages. Ensure you install the -dev versions of packages to include the headers required for the crate build.
Arch Linux
pacman -S clang qt6-base opencv
To support additional OpenCV modules:
pacman -S vtk glew fmt openmpi
Ubuntu
apt install libopencv-dev clang libclang-dev
Opensuse
zypper install opencv-devel clang-devel gcc-c++
Manual Build (Other Linux)
If installing from a repository is not an option, you can build OpenCV manually. You must set the following environment variables before building your Rust project:
PKG_CONFIG_PATH: Location of *.pc files OROpenCV_DIR: Location of *.cmake filesLD_LIBRARY_PATH: Location of the installed *.so files for runtime.
Note: You must also install clang (or a derivative) that contains libclang.so and the clang binary.
pacman -S clang qt6-base opencv