mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.54k stars 1.61k forks source link

opencv dependency not found on arch #4836

Open soloturn opened 5 years ago

soloturn commented 5 years ago

gnome shotwell depends on opencv and has:

subproject = ('facedetect')
add_languages('cpp')
facedetect_dep = dependency('opencv', version : ['>= 2.3.0'], required : true)

arch linux has opencv installed:

$ yay -Ql opencv | grep pc
opencv /usr/include/opencv4/opencv2/optflow/pcaflow.hpp
opencv /usr/include/opencv4/opencv2/optflow/sparse_matching_gpc.hpp
opencv /usr/lib/pkgconfig/opencv4.pc
opencv /usr/share/opencv4/lbpcascades/
opencv /usr/share/opencv4/lbpcascades/lbpcascade_frontalcatface.xml
opencv /usr/share/opencv4/lbpcascades/lbpcascade_frontalface.xml
opencv /usr/share/opencv4/lbpcascades/lbpcascade_frontalface_improved.xml
opencv /usr/share/opencv4/lbpcascades/lbpcascade_profileface.xml
opencv /usr/share/opencv4/lbpcascades/lbpcascade_silverware.xml

despite when building shotwell it gives the error:

facedetect/meson.build:3:0: ERROR:  Dependency "opencv" not found, tried pkgconfig and cmake

the log says it calls

$ pkg-config --modversion opencv
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
Package 'opencv', required by 'virtual:world', not found

while the following would give a result:

$ pkg-config --modversion opencv4
4.0.1

not sure where the error is? is it shotwell? meson? pkg-config?

hagamuna commented 5 years ago

Hey I'm having the same problem, I'm trying to use opencv with mason on Windows, but without luck so far. Note: pkgconfig is also not on Windows. I wish there was a opencv.wrap file, since that download and build logic always works, regardless of platform.

jpakkane commented 5 years ago

If the modulename is opencv4 then it should be found with dependency('opencv4'), not dependency('opencv'). I don't know why the pkg-config name would be different on different platforms, though.

dcbaker commented 5 years ago

This probably has to do with debian shipping opencv 3 and arch shippping opencv 4

soloturn commented 5 years ago

@jpakkane , you would have a suggestion how this should be, considering:

i am slightly confused here. the opencv example from debian seems to allow multiple versions of opencv, but only one .pc file, while arch would allow both versions for all files. https://packages.debian.org/sid/amd64/libopencv-core3.2/filelist

/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2
/usr/share/doc/libopencv-core3.2/changelog.Debian.amd64.gz
...

https://packages.debian.org/sid/amd64/libopencv-dev/filelist

/usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc
...

let me put an example where really 2 versions of a library is there, in this case arch:

$ grep -in core /usr/lib/pkgconfig/avahi-qt*pc
/usr/lib/pkgconfig/avahi-qt4.pc:9:Requires.private: QtCore >= 4.0.0
/usr/lib/pkgconfig/avahi-qt5.pc:9:Requires: Qt5Core >= 5.0.0

how many pkg-config files should be there, what name should be mentioned in it, what name should be specifivied in the build file for the dependency so meson works?

jpakkane commented 5 years ago

We don't really have any say on what pc files are installed and what do they contain. That is a distro issue. We just call pkg-config and use the results. The usual solution in these cases is to do something like:

ocv_dep = dependency('opencv', required: false)
if not ocv_dep.found()
  ocv_dep = dependency('opencv4')
endif
dcbaker commented 5 years ago

I looked at the arch package, they aren't patching the sources. it doesn't look like debian is either. This appears to be a case of opencv upstream changing their pkg-config names to allow opencv 3.x and 4.x to be co-installed.