FS#70286 - [opencv] opencv has been linked with vtk support enabled

Attached to Project: Arch Linux
Opened by imtbl (imtbl) - Sunday, 04 April 2021, 16:56 GMT
Last edited by Antonio Rojas (arojas) - Sunday, 04 April 2021, 18:15 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

opencv has apparently been linked with vtk support, but vtk is not set as a dependency, only as an optional dependency.
This causes the compilation of programs using opencv to fail if vtk is not also installed.
It also affects Python programs using opencv (via hdf5 I think?) which will error with `ImportError: libvtkInteractionStyle.so.1: cannot open shared object file: No such file or directory`.

Additional info:

- Package version: 4.5.2-1

Steps to reproduce:

1. Install `opencv` and `cmake`
2. Download the attached example (code taken from https://docs.opencv.org/master/db/df5/tutorial_linux_gcc_cmake.html) and extract it
3. Run `cd opencv-example ; cmake . ; make`
4. The compilation will fail; see also the included `compilation-error.txt`
This task depends upon

Closed by  Antonio Rojas (arojas)
Sunday, 04 April 2021, 18:15 GMT
Reason for closing:  Fixed
Additional comments about closing:  python-opencv 4.5.2-2
Comment by imtbl (imtbl) - Sunday, 04 April 2021, 17:10 GMT
  • Field changed: Percent Complete (100% → 0%)
I don't think this is covered by optional dependencies at all; the entire library currently can't be used if vtk is not installed, even if vtk isn't even used. You can also see that in the example I attached, where vtk isn't used, but compilation still fails. In that case, opencv should not be linked against vtk or it should be made a dependency instead of an optional dependency.
Comment by Chris Braun (cryzed) - Sunday, 04 April 2021, 17:11 GMT
To illustrate this in more detail:

```
$ python -c "import sys;print(sys.path);import cv2"
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/lib/python3.9/site-packages']
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libvtkInteractionStyle.so.1: cannot open shared object file: No such file or directory
```

Installed is opencv 4.5.2-1.
Comment by Antonio Rojas (arojas) - Sunday, 04 April 2021, 17:12 GMT
To further clarify: your problem is the "find_package( OpenCV REQUIRED )" cmake line. OpenCV is modular, and by using this line you're enforcing linking against *every* single opencv module, which of course requires all their dependencies to be installed. You should only be searching for the modules you need, in your case "find_package( OpenCV REQUIRED COMPONENTS core highgui)"
Comment by Chris Braun (cryzed) - Sunday, 04 April 2021, 17:45 GMT
  • Field changed: Percent Complete (100% → 0%)
See my comment please.
Comment by Antonio Rojas (arojas) - Sunday, 04 April 2021, 17:45 GMT
Reopening to sort out the python dependencies. vtk is indeed new in 4.5.2
Comment by Antonio Rojas (arojas) - Sunday, 04 April 2021, 18:15 GMT
Given the increasing amount of dependencies required by the python bindings, I've split them to a separate package

Loading...