OpenCV and CUDA - updated build notes
Yes, this comes up a lot, and if you're getting mysterious build breaks, maybe it's a mismatch between what version of gcc/g++ CUDA requires, your default compiler.
The symptoms are that cmake completes just fine (so it found a compiler, all the libraries, etc) but then you get a "failed to compile" error when you do a "make -j[number]"
The first thing to do is to run a single-instance make, because the errors will likely be less obtuse. When I did this, I got:
"error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!"
gcc --version told me it was version 9, so there's the problem. But how to get around it?
- Make sure you have a suitable version of gcc and g++ installed (version 8) in our case. On Ubuntu, you can do this with:"sudo apt install -y gcc-8 g++-8"
- Tell cmake about it when you do the pre-build with:"-D CMAKE_C_COMPILER=gcc-8 -D CMAKE_CXX_COMPILER=g++-8"
- You have already installed and verified the pre-requisites.
- The opencv and opencv_contrib source trees have been fully expanded and start at the same level under your source.
- You created a build directory within the opencv source, and you're executing from within that directory.
Hope this helps you out!