I get this error from multible targets:
/usr/bin/ld: ../../lib/libopencv_highgui.so.4.5.5: undefined reference to 'cvSetOpenGlDrawCallback'
/usr/bin/ld: ../../lib/libopencv_highgui.so.4.5.5: undefined reference to 'cvSetOpenGlContext'
/usr/bin/ld: ../../lib/libopencv_highgui.so.4.5.5: undefined reference to 'cvUpdateWindow'
collect2: error: ld returned 1 exit status
cmake command:
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_CUDA=ON \
-D CUDA_ARCH_PTX="" \
-D CUDA_ARCH_BIN="6.1" \
-D WITH_CUBLAS=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=OFF \
-D BUILD_opencv_stitching=OFF \
-D WITH_GSTREAMER=OFF \
-D WITH_GTK=ON \
-D WITH_OPENGL=ON\
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.5.5/modules \
../opencv-4.5.5
It build fine before turning OpenGl on.
1 Like
berak
January 12, 2022, 5:15pm
2
however, the 2nd run seems to have produced conflicting defines for HAVE_OPENGL.
can you clean up all cmake / make artefacts, and start all over ?
then, also show the (clean) cmake output, please ?
i just deleted the build folder to start over, is this the part of the output you are asking for?
-- General configuration for OpenCV 4.5.5 =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): /home/bl/libs/opencv/opencv_contrib-4.5.5/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2022-01-12T18:39:13Z
-- Host: Linux 5.15.8-76051508-generic x86_64
-- CMake: 3.16.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3
-- requested: SSE3
-- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_1 (16 files): + SSSE3 SSE4_1
-- SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: /usr/bin/c++ (ver 9.3.0)
-- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/lib/cuda/lib64 -L/usr/lib/x86_64-linux-gnu
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: stitching world
-- Disabled by dependency: -
-- Unavailable: alphamat cvv hdf java julia matlab ovis python2 python3 sfm ts viz
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI: GTK3
-- GTK+: YES (ver 3.24.20)
-- GThread : YES (ver 2.64.6)
-- GtkGlExt: YES (ver 1.2.0)
-- OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: YES (2.2.5)
-- FFMPEG: YES
-- avcodec: YES (58.54.100)
-- avformat: YES (58.29.100)
-- avutil: YES (56.31.100)
-- swscale: YES (5.5.100)
-- avresample: YES (4.0.0)
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2020.0.0 Gold [2020.0.0]
-- at: /home/bl/libs/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
-- Intel IPP IW: sources (2020.0.0)
-- at: /home/bl/libs/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
-- VA: NO
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
--
-- NVIDIA CUDA: YES (ver 11.2, CUFFT CUBLAS)
-- NVIDIA GPU arch: 61
-- NVIDIA PTX archs:
--
-- cuDNN: YES (ver 8.1.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/bl/libs/opencv/opencv-4.5.5/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.8.10)
-- Libraries: NO
-- numpy: NO (Python3 wrappers can not be generated)
-- install path: -
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
1 Like
I just looked thtough the output, is this part helpful?
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
FindOpenGL found both a legacy GL library:
OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so
and GLVND libraries for OpenGL and GLX:
OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so
OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
modules/highgui/cmake/detect_gtk.cmake:40 (find_package)
modules/highgui/cmake/init.cmake:35 (include)
modules/highgui/cmake/init.cmake:39 (add_backend)
cmake/OpenCVModule.cmake:298 (include)
cmake/OpenCVModule.cmake:361 (_add_modules_1)
cmake/OpenCVModule.cmake:385 (ocv_glob_modules)
CMakeLists.txt:927 (ocv_register_modules)
This warning is for project developers. Use -Wno-dev to suppress it.
I made a paste with the full cmake output: cmake.out - Pastebin.com
dshem
January 13, 2022, 8:08am
5
This is interesting, I also had troubles compiling with OpenGL. It seems like it’s maybe looking for OpenCV C bindings (cvSetOpenGlDrawCallback
, cvSetOpenGlContext
, cvUpdateWindow
) . Did you try to build it by setting OpenGL_GL_PREFERENCE
to GLVND
?
Yes i did, it removes the warning, but the error persist
At the moment i am trying 4.5.4 just to see
So for version 4.5.4 it again builds without OpenGL.
But with OpenGL i get different linker errors:
/usr/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to 'glXGetProcAddressARB'
/usr/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to 'glXGetCurrentDisplay'
/usr/bin/ld: ../../lib/libopencv_core.so.4.5.4: undefined reference to 'glXGetCurrentContext'
2 Likes
dshem
January 13, 2022, 1:54pm
8
Do you have libglx-dev
installed ?
I do have libglx-dev
installed.
Not sure how to apply, but i was looking at the highgui files and in modules/highgui/src/window_gtk.cpp
if found:
#if (GTK_MAJOR_VERSION == 3) && defined(HAVE_OPENGL)
#undef HAVE_OPENGL // no support with GTK3
#endif
So does this mean that OpenGL and GTK 3 are not supported with OpenGL, and i should use GTK 2?
1 Like
I believe this is the issue…
Since everything is updated to new version, say:
Ffmpeg-5
Qt-6
Gtk-3
OpenGL
So, it seems it’s the time for OpenCV to upgrade its compatibility as well…
Within file ./modules/highgui/src/window_gtk.cpp
, it seems for current OpenCV , gtk3 is NOT compatible with OpenGL .
#if (GTK_MAJOR_VERSION == 3) && defined(HAVE_OPENGL)
#undef HAVE_OPENGL // no support with GTK3
#endif
Do you have a patch for Gtk-3 with OpenGL ? From StackOverflow , Gtk-3 should be able to work with OpenGL .
Anyway, my current temporary stupid solution is:
turn OFF WITH_OPENGL with your turn ON WITH_GTK because this GKT is looking for GTK-3 .
Cheers
Install libgtk3.0-cil-dev and try again.
It worked for me.
1 Like