[Slackbuilds-users] opencv-legacy issue

Tim Dickson dickson.tim at googlemail.com
Fri Mar 8 12:10:09 UTC 2019

On 07/03/2019 22:32, Christoph Willing wrote:
> On 8/3/19 3:23 am, Tim Dickson via SlackBuilds-users wrote:
>> On 07/03/2019 07:31, Christoph Willing wrote:
>>> On 7/3/19 6:15 am, Tim Dickson via SlackBuilds-users wrote:
>>>> since updating python to 3.7.2 opencv-legacy fails to build with ..
>>>> [ 85%] Generating pyopencv_generated_include.h,
>>>> pyopencv_generated_funcs.h, pyopencv_generated_types.h,
>>>> pyopencv_generated_type_reg.h, pyopencv_generated_ns_reg.h
>>>> cd /tmp/SBo/opencv-3.1.0/build/modules/python3 && /usr/bin/python3
>>>> /tmp/SBo/opencv-3.1.0/modules/python/python3/..//src2/gen2.py
>>>> /tmp/SBo/opencv-3.1.0/build/modules/python3
>>>> /tmp/SBo/opencv-3.1.0/build/modules/python3/headers.txt
>>>> Note: Class l has more than 1 base class (not supported by Python C
>>>> extensions)
>>>>         Bases:  cv::a, cv::s, cv::s, cv::A, cv::l, cv::g, cv::o, cv::r,
>>>> cv::i, cv::t, cv::h, cv::m
>>>>         Only the first base class will be used
>>>> Note: Class l has more than 1 base class (not supported by Python C
>>>> extensions)
>>>>         Bases:  cv::a, cv::s, cv::s, cv::F, cv::i, cv::l, cv::e, cv::S,
>>>> cv::t, cv::o, cv::r, cv::a, cv::g, cv::e
>>>>         Only the first base class will be used
>>>> Generator error: class l (cname=cv::l) already exists
>>>> modules/python3/CMakeFiles/opencv_python3.dir/build.make:276: recipe for
>>>> target 'modules/python3/pyopencv_generated_include.h' failed
>>>> make[2]: *** [modules/python3/pyopencv_generated_include.h] Error 255
>>>> make[2]: Leaving directory '/tmp/SBo/opencv-3.1.0/build'
>>>> CMakeFiles/Makefile2:14021: recipe for target
>>>> 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
>>>> make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
>>>> make[1]: Leaving directory '/tmp/SBo/opencv-3.1.0/build'
>>>> Makefile:160: recipe for target 'all' failed
>>>> make: *** [all] Error 2
>>>> I've checked, and made sure  opencv-legacy was not previously installed
>>>> when trying to recreate the package.
>>>> any ideas?
>>> It seems python3-3.7.2 is necessary but not sufficient by itself to
>>> trigger this fault. It's actually the presence of the optional numpy3
>>> (which requires python3) during configuration that enables building of
>>> the python3 wrappers, generating the error above during compilation.
>>> The simplest fix is to remove numpy3 from the system. Even with python3
>>> still installed (perhaps needed for other packages), the python3
>>> wrappers will not be generated if numpy is not available during
>>> configuration.
>>> This strategy allows opencv-legacy to build to completion but, of course
>>> without python3 wrappings. Is that a bit deal? Maybe but mitigated by:
>>>       1. possible use of python2 wrappings instead by installing numpy
>>> (not numpy3) which will use built in python2 to generate python2
>>> wrappings.
>>>       2. initially, the only reason for having the opencv-legacy
>>> SlackBuild at all was to satisfy building a particular version of
>>> libkface which was required, in turn, for a particular version of
>>> digikam. AFAIK the python3 wrappings are not needed for this use case.
>>> Serious opencv users that may want the python3 bindings won't be using
>>> opencv-legacy anyway; rather the main opencv. The building of the main
>>> opencv package doesn't suffer this python3/numpy3 problem so I'm
>>> prepared to leave things as they are for opencv-legacy. Of course, if
>>> someone wants to research a fix, I'll happily apply it.
>>> chris
>> I use it for frei0r (an ffmpeg optional dep), and vsxu (a vlc optional
>> dep), and vlc (a direct optional dep)
> Yes, thanks for pointing that out. I only took hard deps into account;
> various optional deps will increase the range of use cases. However in
> these cases, I  don't believe that it (opencv-legacy) needs to be built
> with python3 bindings so this python3/numpy3 issue doesn't affect your
> particular use case.
>> vlc fails to build (with the opencv option) with opencv (as opposed to
>> opencv-legacy )>
> That's not quite right; the build log for vlc on my desktop machine
> shows that plain opencv is available during the build but not recognised
> and therefore not used (source file
> modules/video_filter/opencv_wrapper.c is not compiled). However the
> build itself runs fine, as does the resulting vlc executable.
> chris
i get
checking for libbluray >= 0.6.2... yes
checking for opencv > 2.0... no
configure: error: Library opencv > 2.0 needed for opencv was not found
even though ls /var/log/packages/opencv* gives

I think the problem is that opencv version 4 reports itself as opencv4 
to pkg-config whereas opencv-legacy reports itself as opencv
copying /usr/lib64/pkgconfig/opencv4 to /usr/lib64/pkgconfig/opencv gets 
further and bails at

/usr/include/opencv4/opencv2/core/cvdef.h:109:47: warning: "__cplusplus" 
is not defined [-Wundef]
  #  if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
In file included from /usr/include/opencv4/opencv2/core/types_c.h:82:0,
                  from /usr/include/opencv4/opencv2/core/core_c.h:48,
                  from video_filter/opencv_wrapper.c:42:
/usr/include/opencv4/opencv2/core/cvdef.h:647:7: warning: "__cplusplus" 
is not defined [-Wundef]
  #  if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
/usr/include/opencv4/opencv2/core/cvdef.h:656:4: error: #error "OpenCV 
4.x+ requires enabled C++11 support"
  #  error "OpenCV 4.x+ requires enabled C++11 support"
/usr/include/opencv4/opencv2/core/cvdef.h:661:17: fatal error: array: No 
such file or directory
compilation terminated.
Makefile:21527: recipe for target 
'video_filter/libopencv_wrapper_plugin_la-opencv_wrapper.lo' failed
make[4]: *** 
[video_filter/libopencv_wrapper_plugin_la-opencv_wrapper.lo] Error 1
make[4]: Leaving directory '/tmp/SBo/vlc-3.0.6/modules'
Makefile:26254: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/tmp/SBo/vlc-3.0.6/modules'
Makefile:11314: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/tmp/SBo/vlc-3.0.6/modules'
Makefile:1539: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/SBo/vlc-3.0.6'
Makefile:1424: recipe for target 'all' failed
make: *** [all] Error 2

To fix that error I had to modify the slackbuild, specifically the line 
calling ./configure see below
CXXFLAGS="$SLKCFLAGS -std=c++11" \

Once I did this, vlc completed with just opencv4 installed, and played a 
test mp4 file.

If you had both opencv and opencv-legacy installed at the same time you 
would not notice, but vlc would be built with the legacy version, 
instead of v4, because they are stored in different locations. ( 
..../opencv verses ..../opencv4/opencv  ) and vlc checks the old version 
not the new one.
whether the pkg-config issue is an opencv one or a vlc one is open to 
regards, Tim

More information about the SlackBuilds-users mailing list