I complied using this:
g++ -ggdb opengl_interop.cpp -o opengl_interop `pkg-config --cflags --libs opencv` -lGL -lGLU -lX11
and then run
./opengl_interop -c
result
Usage: opengl_interop [params]
-c, --camera (value:true)
use camera or not
-f, --file
movie file name
-h, --help (value:false)
print help info
[ INFO:0] Initialize OpenCL runtime...
OpenCV(3.4.1) Error: Unknown error code -222 (OpenCL: Can't create context for OpenGL interop) in initializeContextFromGL, file /OpenCV/modules/core/src/opengl.cpp, line 1683 Exception: OpenCV(3.4.1) /OpenCV/modules/core/src/opengl.cpp:1683: error: (-222) OpenCL: Can't create context for OpenGL interop in function initializeContextFromGL
I've tried a few other programs that require the same interoperability and I'm not able to get them to work either.