Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 704518

Summary: media-libs/opencv-4.1.2-r2 USE="-contrib cuda -download" : CMake Error: CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib'
Product: Gentoo Linux Reporter: Daniel M. Weeks <dan>
Component: Current packagesAssignee: Amy Liffey <amynka>
Status: RESOLVED FIXED    
Severity: normal CC: albert, alex, DaBler, pacho, phobosk, rossbridger.cc, sam, skobkin-ru
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=701712
https://github.com/gentoo/gentoo/pull/17899
https://bugs.gentoo.org/show_bug.cgi?id=792282
Whiteboard:
Package list:
Runtime testing required: ---

Description Daniel M. Weeks 2020-01-02 03:17:12 UTC
With USE="-contrib cuda -download" the following error occurs:

CMake Error at modules/core/CMakeLists.txt:40 (message):
  CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib'
  repository: https://github.com/opencv/opencv_contrib

However, the combination USE="contrib cuda -download", causes the following additional error:

/tmp/portage/media-libs/opencv-4.1.2-r2/work/opencv-4.1.2/modules/core/include/opencv2/core/base.hpp:320:40: error: expected constructor, destructor, or type conversion before ‘(’ token
 #define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ )
                                        ^
/tmp/portage/media-libs/opencv-4.1.2-r2/work/opencv_contrib-4.1.2/modules/cudaoptflow/src/nvidiaOpticalFlow.cpp:15:1: note: in expansion of macro ‘CV_Error’
 CV_Error(cv::Error::HeaderIsNull, "Nvidia Optical Flow headers not found. Make sure cmake downloads it properly");  
 ^~~~~~~~

However, USE="contrib cuda download" will also "fail" if FEATURES="network-sandbox":

-- ADE: Download: v0.1.1f.zip
-- Try 1 failed
--
=======================================================================
  Couldn't download files from the Internet.
  Please check the Internet access on this host.
=======================================================================

CMake Warning at cmake/OpenCVDownload.cmake:203 (message):
  ADE: Download failed: 6;"Couldn't resolve host name"

  For details please refer to the download log file:


  /tmp/portage/media-libs/opencv-4.1.2-r2/work/opencv-4.1.2-abi_x86_64.amd64/CMakeDownloadLog.txt

This will not cause cmake to stop and it will try building as if USE=-download. (This could easily be missed and is inconsistent with the USE flag, leading to the above "Nvidia Optical Flow headers not found" error.)

Reproducible: Always
Comment 1 David Bařina 2020-01-17 11:29:24 UTC
I can confirm this issue.

Moreover, even if I installl the =media-libs/opencv-4.1.2-r2 with USE="contrib cuda download" and FEATURES="-network-sandbox", the "pkg-config --cflags opencv4" misses the following include path on my system:

-I/opt/cuda/targets/x86_64-linux/include

Once this is added to CFLAGS in my Makefile, everything works properly.
Comment 2 David Bařina 2020-01-17 17:16:51 UTC
Also USE="cuda" does not work with gcc > 8.3
Comment 3 Samuel Bernardo 2020-01-21 16:02:52 UTC
Same issue here.
I will test with David Bařina suggestions.
Comment 4 Pacho Ramos gentoo-dev 2020-03-08 19:30:39 UTC
I have tried to run cuda_sanitize (from cuda.eclass) to try to get right gcc version used by it still fails :/

Maybe it is not respecting NVCCFLAGS variable. It seems detection is done using variables like NVCC_FLAGS_EXTRA
Comment 5 Ultratux 2020-08-01 18:58:56 UTC
Looks like the situation is unchanged with media-libs/opencv-4.1.2-r3

I can't compile it successfully, even using gcc-8.3.0 and USE="contrib cuda download"

/var/tmp/portage/media-libs/opencv-4.1.2-r3/work/opencv-4.1.2/modules/core/include/opencv2/core/base.hpp:320:40: error: expected constructor, destructor, or type conversion before ‘(’ token
 #define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ )
                                        ^
/var/tmp/portage/media-libs/opencv-4.1.2-r3/work/opencv_contrib-4.1.2/modules/cudaoptflow/src/nvidiaOpticalFlow.cpp:15:1: note: in expansion of macro ‘CV_Error’
 CV_Error(cv::Error::HeaderIsNull, "Nvidia Optical Flow headers not found. Make sure cmake downloads it properly");
Comment 6 Larry the Git Cow gentoo-dev 2020-11-03 07:18:37 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c92eaa6a7d93400503334e9c65df2b8e400ab90f

commit c92eaa6a7d93400503334e9c65df2b8e400ab90f
Author:     Ross Charles Campbell <rossbridger.cc@gmail.com>
AuthorDate: 2020-10-18 14:59:46 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-11-03 07:18:26 +0000

    media-libs/opencv: various fixes
    
     - Explicitly depends on virtual/lapacke to prevent its cmake build scripts from
    implicitly disabling lapack support when it can't find lapacke.h.
    
     - Link with cblas when sci-libs/lapack is supplimented as the default lapack
    implementation.
    
     - examples USE requires contribdnn USE to be enabled to prevent build failure.
    
    Closes: https://bugs.gentoo.org/700176
    Closes: https://bugs.gentoo.org/749681
    Closes: https://bugs.gentoo.org/717812
    Closes: https://bugs.gentoo.org/701790
    Closes: https://bugs.gentoo.org/704518
    Package-Manager: Portage-3.0.8, Repoman-3.0.1
    Signed-off-by: Ross Charles Campbell <rossbridger.cc@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/17964
    Signed-off-by: Sam James <sam@gentoo.org>

 .../opencv-4.5.0-link-with-cblas-for-lapack.patch      | 18 ++++++++++++++++++
 media-libs/opencv/opencv-4.5.0.ebuild                  |  8 +++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)