Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 704518 - media-libs/opencv-4.1.2-r2 USE="-contrib cuda -download" : CMake Error: CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib'
Summary: media-libs/opencv-4.1.2-r2 USE="-contrib cuda -download" : CMake Error: CUDA:...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 2 votes (vote)
Assignee: Amy Liffey
Depends on:
Reported: 2020-01-02 03:17 UTC by Daniel M. Weeks
Modified: 2020-05-07 15:28 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
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'

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:
-- 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:


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:


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