opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.42k stars 5.76k forks source link

Failed to build opencv 4.6.0 on CentOS 7 due to missing opengl symbols used by `rgbd/dynafu.cpp` #3315

Closed xkszltl closed 2 years ago

xkszltl commented 2 years ago

Re-filing in main repo since it's dead silence in contrib:

System information (version)
Detailed description

Undefined reference to glGenRenderbuffersEXT and several other OpenGL functions. Was fine a few versions (4.5.5) and months ago (2022-04-27). Not sure if it's due to changes of something else in system or due to opencv itself.

$ cmake --build . -- -j1                                                                                 
[1/8] cd /media/Scratch/tmp.FilPhE8QZU/opencv/build/modules/cvv && /usr/local/bin/cmake -E cmake_autogen /media/Scratch/tmp.FilPhE8QZU/opencv/build/modules/cvv/CMakeFiles/opencv_cvv_autogen.dir/AutogenInfo.json Release
[2/5] : && /opt/rh/devtoolset-11/root/usr/bin/g++ -fPIC -fdebug-prefix-map='/media/Scratch/tmp.FilPhE8QZU'='/usr/local/src' -g   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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 -flto  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG  -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -shared -Wl,-soname,libopencv_rgbd.so.406 -o lib/libopencv_rgbd.so.4.6.0 modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/colored_kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/colored_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_cleaner.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_registration.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_to_3d.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dqb.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dynafu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dynafu_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/fast_icp.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/hash_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/kinfu_frame.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/large_kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/linemod.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/nonrigid_icp.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/normal.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/odometry.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/plane.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/pose_graph.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/tsdf_functions.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/utils.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/volume.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/warpfield.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/opencl_kernels_rgbd.cpp.o  -Wl,-rpath,/media/Scratch/tmp.FilPhE8QZU/opencv/build/lib::::::::::::::::::::::::::::::  lib/libopencv_calib3d.so.4.6.0  -ldl  -lm  -lpthread  -lrt  3rdparty/lib/libippiw.a  3rdparty/ippicv/ippicv_lnx/icv/lib/intel64/libippicv.a  /lib64/libOpenGL.so  /lib64/libGLX.so  /lib64/libGLU.so  lib/libopencv_features2d.so.4.6.0  lib/libopencv_flann.so.4.6.0  lib/libopencv_imgproc.so.4.6.0  lib/libopencv_core.so.4.6.0 && :
FAILED: lib/libopencv_rgbd.so.4.6.0 
: && /opt/rh/devtoolset-11/root/usr/bin/g++ -fPIC -fdebug-prefix-map='/media/Scratch/tmp.FilPhE8QZU'='/usr/local/src' -g   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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 -flto  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG  -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -shared -Wl,-soname,libopencv_rgbd.so.406 -o lib/libopencv_rgbd.so.4.6.0 modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/colored_kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/colored_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_cleaner.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_registration.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/depth_to_3d.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dqb.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dynafu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dynafu_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/fast_icp.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/hash_tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/kinfu_frame.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/large_kinfu.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/linemod.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/nonrigid_icp.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/normal.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/odometry.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/plane.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/pose_graph.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/tsdf.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/tsdf_functions.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/utils.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/volume.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/warpfield.cpp.o modules/rgbd/CMakeFiles/opencv_rgbd.dir/opencl_kernels_rgbd.cpp.o  -Wl,-rpath,/media/Scratch/tmp.FilPhE8QZU/opencv/build/lib::::::::::::::::::::::::::::::  lib/libopencv_calib3d.so.4.6.0  -ldl  -lm  -lpthread  -lrt  3rdparty/lib/libippiw.a  3rdparty/ippicv/ippicv_lnx/icv/lib/intel64/libippicv.a  /lib64/libOpenGL.so  /lib64/libGLX.so  /lib64/libGLU.so  lib/libopencv_features2d.so.4.6.0  lib/libopencv_flann.so.4.6.0  lib/libopencv_imgproc.so.4.6.0  lib/libopencv_core.so.4.6.0 && :
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o: in function `cv::dynafu::DynaFu::create(cv::Ptr<cv::kinfu::Params> const&)':
/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:159: undefined reference to `glGenRenderbuffersEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:160: undefined reference to `glBindRenderbufferEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:161: undefined reference to `glRenderbufferStorageEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:164: undefined reference to `glGenFramebuffersEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:165: undefined reference to `glBindFramebufferEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:167: undefined reference to `glFramebufferRenderbufferEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:171: undefined reference to `glGenRenderbuffersEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:172: undefined reference to `glBindRenderbufferEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:173: undefined reference to `glRenderbufferStorageEXT'
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /tmp/ccFIHCan.ltrans1.ltrans.o:/usr/local/src/opencv/build/../contrib/modules/rgbd/src/dynafu.cpp:175: undefined reference to `glFramebufferRenderbufferEXT'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

It links to:

$ realpath -e /lib64/lib{OpenGL,GLX,GLU}.so
/usr/lib64/libOpenGL.so.0.0.0
/usr/lib64/libGLX.so.0.0.0
/usr/lib64/libGLU.so.1.3.1

Those OpenGL libs doesn't contain the glExt functions required:

$ readelf -a /lib64/libOpenGL.so | grep -egl{Bind,Frame,Gen,Render}
    57: 00000000000163e0     0 FUNC    GLOBAL DEFAULT    13 glBindVertexArray
    67: 0000000000018100     0 FUNC    GLOBAL DEFAULT    13 glGenerateMipmap
   162: 0000000000016300     0 FUNC    GLOBAL DEFAULT    13 glBindRenderbuffer
   170: 0000000000017fc0     0 FUNC    GLOBAL DEFAULT    13 glGenBuffers
   196: 0000000000016360     0 FUNC    GLOBAL DEFAULT    13 glBindTexture
   225: 0000000000016280     0 FUNC    GLOBAL DEFAULT    13 glBindFramebuffer
   227: 0000000000016340     0 FUNC    GLOBAL DEFAULT    13 glBindSamplers
   229: 0000000000017ec0     0 FUNC    GLOBAL DEFAULT    13 glFramebufferRenderbuffer
   257: 000000000001b7c0     0 FUNC    GLOBAL DEFAULT    13 glRenderbufferStorageMultisample
   262: 000000000001b780     0 FUNC    GLOBAL DEFAULT    13 glRenderMode
   301: 00000000000162a0     0 FUNC    GLOBAL DEFAULT    13 glBindImageTexture
   314: 0000000000016180     0 FUNC    GLOBAL DEFAULT    13 glBindAttribLocation
   321: 00000000000180c0     0 FUNC    GLOBAL DEFAULT    13 glGenTransformFeedbacks
   333: 0000000000018040     0 FUNC    GLOBAL DEFAULT    13 glGenQueries
   346: 00000000000162c0     0 FUNC    GLOBAL DEFAULT    13 glBindImageTextures
   403: 0000000000016420     0 FUNC    GLOBAL DEFAULT    13 glBindVertexBuffers
   418: 00000000000163c0     0 FUNC    GLOBAL DEFAULT    13 glBindTransformFeedback
   430: 0000000000018120     0 FUNC    GLOBAL DEFAULT    13 glGenerateTextureMipmap
   449: 00000000000163a0     0 FUNC    GLOBAL DEFAULT    13 glBindTextures
   454: 0000000000017f60     0 FUNC    GLOBAL DEFAULT    13 glFramebufferTextureLayer
   468: 0000000000016260     0 FUNC    GLOBAL DEFAULT    13 glBindFragDataLocationIndexed
   484: 0000000000016240     0 FUNC    GLOBAL DEFAULT    13 glBindFragDataLocation
   543: 00000000000162e0     0 FUNC    GLOBAL DEFAULT    13 glBindProgramPipeline
   562: 0000000000017ea0     0 FUNC    GLOBAL DEFAULT    13 glFramebufferParameteri
   614: 0000000000016380     0 FUNC    GLOBAL DEFAULT    13 glBindTextureUnit
   619: 00000000000161a0     0 FUNC    GLOBAL DEFAULT    13 glBindBuffer
   637: 0000000000018080     0 FUNC    GLOBAL DEFAULT    13 glGenSamplers
   697: 0000000000017fe0     0 FUNC    GLOBAL DEFAULT    13 glGenFramebuffers
   716: 0000000000016220     0 FUNC    GLOBAL DEFAULT    13 glBindBuffersRange
   723: 000000000001b7a0     0 FUNC    GLOBAL DEFAULT    13 glRenderbufferStorage
   805: 0000000000016200     0 FUNC    GLOBAL DEFAULT    13 glBindBuffersBase
   834: 00000000000180a0     0 FUNC    GLOBAL DEFAULT    13 glGenTextures
   847: 0000000000018060     0 FUNC    GLOBAL DEFAULT    13 glGenRenderbuffers
   878: 0000000000018020     0 FUNC    GLOBAL DEFAULT    13 glGenProgramPipelines
   904: 00000000000161c0     0 FUNC    GLOBAL DEFAULT    13 glBindBufferBase
   910: 0000000000017ee0     0 FUNC    GLOBAL DEFAULT    13 glFramebufferTexture
   917: 0000000000016400     0 FUNC    GLOBAL DEFAULT    13 glBindVertexBuffer
   923: 0000000000018000     0 FUNC    GLOBAL DEFAULT    13 glGenLists
   979: 0000000000017f00     0 FUNC    GLOBAL DEFAULT    13 glFramebufferTexture1D
   981: 00000000000180e0     0 FUNC    GLOBAL DEFAULT    13 glGenVertexArrays
  1005: 0000000000017f20     0 FUNC    GLOBAL DEFAULT    13 glFramebufferTexture2D
  1028: 00000000000161e0     0 FUNC    GLOBAL DEFAULT    13 glBindBufferRange
  1039: 0000000000017f40     0 FUNC    GLOBAL DEFAULT    13 glFramebufferTexture3D
  1066: 0000000000016320     0 FUNC    GLOBAL DEFAULT    13 glBindSampler
Steps to reproduce

Here's the cmake arg list I'm using:

Issue submission checklist
alalek commented 2 years ago

Please don't open duplicates. This is just a waste of time. duplicate of #3299

xkszltl commented 2 years ago

My concern is it didn't get any attention so I'm trying to move it to main repo instead of duplicate. Not sure if contrib repo is actively monitored.