未找到包“opencv4”

未找到包“opencv4”

我的 makefile 中有这一行:

$(CLINAME): $(LIBNAME) main.c
    $(CC) -o $@ main.c -std=c99 `pkg-config --cflags --libs opencv4` -Iinclude -L. -l$@  -lm

我正在尝试运行我的代码,但是当我写下以下内容时出现此错误:

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

请问该如何修复?

答案1

OpenCV 可从 Ubuntu“universe”存储库获得 - 除非您需要与发行版打包的版本不同的版本,否则我建议您通过apt而不是从第三方安装它。发展元包被命名libopencv-dev,并且它的当前版本

软件包 libopencv-dev

focal (20.04LTS) (libdevel): development files for opencv [universe]
4.2.0+dfsg-5: amd64 arm64 armhf ppc64el riscv64 s390x
jammy (22.04LTS) (libdevel): development files for opencv [universe]
4.5.4+dfsg-9ubuntu4: amd64 arm64 armhf ppc64el riscv64 s390x
lunar (23.04) (libdevel): development files for opencv [universe]
4.6.0+dfsg-11: amd64 arm64 armhf ppc64el riscv64 s390x
mantic (23.10) (libdevel): development files for opencv [universe]
4.6.0+dfsg-13build1: amd64 arm64 armhf ppc64el riscv64 s390x
noble (libdevel): development files for opencv [universe]
4.6.0+dfsg-13build5: amd64 arm64 armhf ppc64el riscv64 s390x

安装libopencv-dev还将安装依赖的运行时库1和支持opencv4.pc文件pkg-config


  1. 我不确定它是否能安装全部OpenCV 组件或只是核心组件,你需要解析输出以apt depends libopencv-dev确保

相关内容