Skip to content

sfm: link with Glog_LIBS #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

shr-project
Copy link

  • in 4.5.0 there was explicit linkage with GLOG_LIBRARY, but since 4.5.1 with:
    23ee62a

    it's gone, probably because Glog_FOUND is already set from Ceres,
    but then GLOG_LIBRARIES is empty in LIBMV_LIGHT_LIBS and build with gold fails:

FAILED: bin/example_tutorial_perspective_correction
: && TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -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 -mssse3 -DNDEBUG -DNDEBUG -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0 -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot= -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native= -fvisibility-inlines-hidden -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,--gc-sections -Wl,--as-needed samples/cpp/CMakeFiles/example_tutorial_perspective_correction.dir/tutorial_code/features2D/Homography/perspective_correction.cpp.o -o bin/example_tutorial_perspective_correction -ldl -lm -lpthread -lrt lib/libopencv_gapi.so.4.5.2 lib/libopencv_stitching.so.4.5.2 lib/libopencv_ts.so.4.5.2 lib/libopencv_alphamat.so.4.5.2 lib/libopencv_aruco.so.4.5.2 lib/libopencv_bgsegm.so.4.5.2 lib/libopencv_bioinspired.so.4.5.2 lib/libopencv_ccalib.so.4.5.2 lib/libopencv_dnn_objdetect.so.4.5.2 lib/libopencv_dnn_superres.so.4.5.2 lib/libopencv_dpm.so.4.5.2 lib/libopencv_face.so.4.5.2 lib/libopencv_fuzzy.so.4.5.2 lib/libopencv_hfs.so.4.5.2 lib/libopencv_img_hash.so.4.5.2 lib/libopencv_intensity_transform.so.4.5.2 lib/libopencv_line_descriptor.so.4.5.2 lib/libopencv_mcc.so.4.5.2 lib/libopencv_quality.so.4.5.2 lib/libopencv_rapid.so.4.5.2 lib/libopencv_reg.so.4.5.2 lib/libopencv_rgbd.so.4.5.2 lib/libopencv_saliency.so.4.5.2 lib/libopencv_sfm.so.4.5.2 lib/libopencv_stereo.so.4.5.2 lib/libopencv_structured_light.so.4.5.2 lib/libopencv_superres.so.4.5.2 lib/libopencv_surface_matching.so.4.5.2 lib/libopencv_tracking.so.4.5.2 lib/libopencv_videostab.so.4.5.2 lib/libopencv_wechat_qrcode.so.4.5.2 lib/libopencv_xfeatures2d.so.4.5.2 lib/libopencv_xobjdetect.so.4.5.2 lib/libopencv_xphoto.so.4.5.2 lib/libopencv_shape.so.4.5.2 lib/libopencv_highgui.so.4.5.2 lib/libopencv_datasets.so.4.5.2 lib/libopencv_ml.so.4.5.2 lib/libopencv_plot.so.4.5.2 lib/libopencv_phase_unwrapping.so.4.5.2 lib/libopencv_optflow.so.4.5.2 lib/libopencv_ximgproc.so.4.5.2 lib/libopencv_videoio.so.4.5.2 lib/libopencv_video.so.4.5.2 lib/libopencv_dnn.so.4.5.2 lib/libopencv_imgcodecs.so.4.5.2 lib/libopencv_objdetect.so.4.5.2 lib/libopencv_calib3d.so.4.5.2 lib/libopencv_features2d.so.4.5.2 lib/libopencv_flann.so.4.5.2 lib/libopencv_photo.so.4.5.2 lib/libopencv_imgproc.so.4.5.2 lib/libopencv_core.so.4.5.2 -Wl,-rpath-link,TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/build/lib && :
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::LogMessage(char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::stream()'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::~LogMessage()'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::kLogSiteUninitialized'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'fLI::FLAGS_v'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::InitVLOG3__(int**, int*, char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::LogMessageFatal(char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status

Add Glog_LIBS which is set to the same value as GLOG_LIBRARIES used to be.

Signed-off-by: Martin Jansa [email protected]

* in 4.5.0 there was explicit linkage with GLOG_LIBRARY, but since 4.5.1 with:
  opencv@23ee62a

  it's gone, probably because Glog_FOUND is already set from Ceres,
  but then GLOG_LIBRARIES is empty in LIBMV_LIGHT_LIBS and build with gold fails:

FAILED: bin/example_tutorial_perspective_correction
: && TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux/x86_64-oe-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include  -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native=  -fvisibility-inlines-hidden  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include  -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot   -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 -mssse3 -DNDEBUG  -DNDEBUG  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include  -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0=/usr/src/debug/opencv/4.5.2-r0                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot=                      -fdebug-prefix-map=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native=  -fvisibility-inlines-hidden  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -ITOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include  -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now  -Wl,--gc-sections -Wl,--as-needed samples/cpp/CMakeFiles/example_tutorial_perspective_correction.dir/tutorial_code/features2D/Homography/perspective_correction.cpp.o -o bin/example_tutorial_perspective_correction  -ldl  -lm  -lpthread  -lrt  lib/libopencv_gapi.so.4.5.2  lib/libopencv_stitching.so.4.5.2  lib/libopencv_ts.so.4.5.2  lib/libopencv_alphamat.so.4.5.2  lib/libopencv_aruco.so.4.5.2  lib/libopencv_bgsegm.so.4.5.2  lib/libopencv_bioinspired.so.4.5.2  lib/libopencv_ccalib.so.4.5.2  lib/libopencv_dnn_objdetect.so.4.5.2  lib/libopencv_dnn_superres.so.4.5.2  lib/libopencv_dpm.so.4.5.2  lib/libopencv_face.so.4.5.2  lib/libopencv_fuzzy.so.4.5.2  lib/libopencv_hfs.so.4.5.2  lib/libopencv_img_hash.so.4.5.2  lib/libopencv_intensity_transform.so.4.5.2  lib/libopencv_line_descriptor.so.4.5.2  lib/libopencv_mcc.so.4.5.2  lib/libopencv_quality.so.4.5.2  lib/libopencv_rapid.so.4.5.2  lib/libopencv_reg.so.4.5.2  lib/libopencv_rgbd.so.4.5.2  lib/libopencv_saliency.so.4.5.2  lib/libopencv_sfm.so.4.5.2  lib/libopencv_stereo.so.4.5.2  lib/libopencv_structured_light.so.4.5.2  lib/libopencv_superres.so.4.5.2  lib/libopencv_surface_matching.so.4.5.2  lib/libopencv_tracking.so.4.5.2  lib/libopencv_videostab.so.4.5.2  lib/libopencv_wechat_qrcode.so.4.5.2  lib/libopencv_xfeatures2d.so.4.5.2  lib/libopencv_xobjdetect.so.4.5.2  lib/libopencv_xphoto.so.4.5.2  lib/libopencv_shape.so.4.5.2  lib/libopencv_highgui.so.4.5.2  lib/libopencv_datasets.so.4.5.2  lib/libopencv_ml.so.4.5.2  lib/libopencv_plot.so.4.5.2  lib/libopencv_phase_unwrapping.so.4.5.2  lib/libopencv_optflow.so.4.5.2  lib/libopencv_ximgproc.so.4.5.2  lib/libopencv_videoio.so.4.5.2  lib/libopencv_video.so.4.5.2  lib/libopencv_dnn.so.4.5.2  lib/libopencv_imgcodecs.so.4.5.2  lib/libopencv_objdetect.so.4.5.2  lib/libopencv_calib3d.so.4.5.2  lib/libopencv_features2d.so.4.5.2  lib/libopencv_flann.so.4.5.2  lib/libopencv_photo.so.4.5.2  lib/libopencv_imgproc.so.4.5.2  lib/libopencv_core.so.4.5.2  -Wl,-rpath-link,TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/build/lib && :
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::LogMessage(char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::stream()'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessage::~LogMessage()'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::kLogSiteUninitialized'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'fLI::FLAGS_v'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::InitVLOG3__(int**, int*, char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::LogMessageFatal(char const*, int)'
lib/libopencv_sfm.so.4.5.2: error: undefined reference to 'google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status

  Add Glog_LIBS which is set to the same value as GLOG_LIBRARIES used to be.

Signed-off-by: Martin Jansa <[email protected]>
@shr-project shr-project mentioned this pull request Apr 14, 2021
5 tasks
@alalek
Copy link
Member

alalek commented Apr 14, 2021

Perhaps we need to upgrade try_compile() check above (it is without Glog_LIBS too).

How is Ceres build? Is it linked as a static binaries (.a)?

@shr-project
Copy link
Author

Perhaps we need to upgrade try_compile() check above (it is without Glog_LIBS too).

How is Ceres build? Is it linked as a static binaries (.a)?

Looks like it's reproducible without Ceres available as well:

-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- Checking SFM glog/gflags deps... TRUE
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
-- Allocator metrics storage type: 'long long'
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- Performing Test HAVE_CXX_WNO_DEPRECATED

Looks like Glog_FOUND was set by cnn_3dobj module, not ceres

grep Glog_FOUND log.conf
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/cnn_3dobj/FindGlog.cmake(2):  unset(Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/cnn_3dobj/FindGlog.cmake(9):  set(Glog_FOUND 1 )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/cnn_3dobj/CMakeLists.txt(24):  if(Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(12):  if(NOT Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(16):  if(NOT Gflags_FOUND OR NOT Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(34):  if(( gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS ) AND ( glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS ) )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(12):  if(NOT Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(16):  if(NOT Gflags_FOUND OR NOT Glog_FOUND )
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(34):  if(( gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS ) AND ( glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS ) )

@alalek
Copy link
Member

alalek commented Apr 14, 2021

Could you try the patch from #2924 with your case? (disables malformed FindGlog.cmake from cnn_3dobj module)

@shr-project
Copy link
Author

Could you try the patch from #2924 with your case? (disables malformed FindGlog.cmake from cnn_3dobj module)

Seems to fail the same way as before my patch, whole log here:
http://errors.yoctoproject.org/Errors/Details/576552/

@alalek
Copy link
Member

alalek commented Apr 15, 2021

Could you please check content of SFM_GLOG_GFLAGS_TEST_CACHE_KEY variable in CMakeCache.txt? (it should include ${GLOG_LIBRARIES} value)

If this value is missing, could you please add mapping Glog_LIBS => GLOG_LIBRARIES as it is done for *_INCLUDE_DIRS on lines 27-32 (to follow modern CMake practices)


BTW, Looks like there are no more places in OpenCV where is defined or used Glog_LIBS (except cnn_3dobj which is broken and disabled), so current patch looks strange.

@zboszor
Copy link

zboszor commented Apr 16, 2021

Another datapoint: when trying to build opencv 4.5.2 in Yocto 3.3 (current master) with meta-clang added, there is no build issue.
Instead, there's a runtime issue because of the missing symbols in the sfm library:

# ldd -r -d /usr/lib/libopencv_sfm.so.4.5.2
	linux-vdso.so.1 (0x00007ffcf11bb000)
	libopencv_core.so.4.5 => /usr/lib/libopencv_core.so.4.5 (0x00007f66ba4c1000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f66ba2f3000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f66ba1b1000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f66ba197000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f66b9fd1000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f66b9fcc000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f66b9faa000)
	libtbb.so.2 => /usr/lib/libtbb.so.2 (0x00007f66b9f78000)
	libz.so.1 => /usr/lib/libz.so.1 (0x00007f66b9f5e000)
	/usr/lib/ld-linux-x86-64.so.2 (0x00007f66ba8b8000)
	librt.so.1 => /usr/lib/librt.so.1 (0x00007f66b9f53000)
undefined symbol: _ZN6google21kLogSiteUninitializedE	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google21kLogSiteUninitializedE	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN3fLI7FLAGS_vE	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google11InitVLOG3__EPPiS0_PKci	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google10LogMessage6streamEv	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google10LogMessageC1EPKci	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google15LogMessageFatalD1Ev	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google10LogMessageD1Ev	(/usr/lib/libopencv_sfm.so.4.5.2)
undefined symbol: _ZN6google15LogMessageFatalC1EPKci	(/usr/lib/libopencv_sfm.so.4.5.2)

After rebuilding with this patch there's no missing symbol and a python test program using opencv+imageai works.

@shr-project
Copy link
Author

Could you please check content of SFM_GLOG_GFLAGS_TEST_CACHE_KEY variable in CMakeCache.txt? (it should include ${GLOG_LIBRARIES} value)

core2-64-oe-linux/opencv/4.5.2-r0$ grep SFM_GLOG_GFLAGS_TEST_CACHE_KEY build/CMakeCache.txt
SFM_GLOG_GFLAGS_TEST_CACHE_KEY:INTERNAL= ~ /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include ~  ~ gflags_share

If this value is missing, could you please add mapping Glog_LIBS => GLOG_LIBRARIES as it is done for *_INCLUDE_DIRS on lines 27-32 (to follow modern CMake practices)

This didn't help when cnn_3dobj was disabled with your change, because Glog_LIBS wasn't defined as well and

find_package(Glog QUIET)

in sfm didn't find Glog at all, here is relevant section of CMake output:

CMake Debug Log at /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt:13 (find_package):
  find_package considered the following paths for Glog.cmake

    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/share/cmake/Modules/FindGlog.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/share/cmake/Modules/FindGlog.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/share/cmake-3.19/Modules/FindGlog.cmake

  The file was not found.

  <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].

    none

  CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
  [CMAKE_FIND_USE_CMAKE_PATH].

    none

  Env variable Glog_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
  [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  Paths specified by the find_package HINTS option.
    none

  Standard system environment variables
  [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].

    /OE/build/oe-core/tmp-glibc/sysroots-uninative/x86_64-linux/usr
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/python3-native
    /OE/build/oe-core/openembedded-core/scripts
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr/bin/x86_64-oe-linux
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/bin/crossscripts
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native/usr
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot-native
    /OE/build/oe-core/bitbake
    /OE/build/oe-core/tmp-glibc/hosttools



  CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].

    none

  CMake variables defined in the Platform file
  [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].

    /usr/local
    /usr
    /
    /usr/X11R6
    /usr/pkg
    /opt



  CMake System Package Registry
  [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].

    none
   none

  find_package considered the following locations for the Config module:

    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/bin/crossscripts/GlogConfig.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/bin/crossscripts/glog-config.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/GlogConfig.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/glog-config.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/GlogConfig.cmake
    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake

  The file was found at

    /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake



   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
CMake Debug Log at /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt:13 (find_package):


   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(16):  if(NOT Gflags_FOUND OR NOT Glog_FOUND )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(27):  if(NOT DEFINED GFLAGS_INCLUDE_DIRS AND DEFINED GFLAGS_INCLUDE_DIR )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(28):  set(GFLAGS_INCLUDE_DIRS /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(30):  if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(33):  if(NOT DEFINED GLOG_LIBRARIES AND DEFINED Glog_LIBS )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(37):  if(( gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS ) AND ( glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS ) )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(38):  set(__cache_key  ~ /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include ~  ~ gflags_shared )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(39):  if(NOT DEFINED SFM_GLOG_GFLAGS_TEST_CACHE_KEY OR NOT ( SFM_GLOG_GFLAGS_TEST_CACHE_KEY STREQUAL __cache_key ) )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(40):  set(__fname /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/cmake/checks/check_glog_gflags.cpp )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(41):  try_compile(SFM_GLOG_GFLAGS_TEST /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/build /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/cmake/checks/check_glog_gflags.cpp CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=;/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include LINK_LIBRARIES  gflags_shared OUTPUT_VARIABLE __output )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(47):  if(NOT SFM_GLOG_GFLAGS_TEST )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(53):  set(SFM_GLOG_GFLAGS_TEST TRUE CACHE INTERNAL  )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(54):  set(SFM_GLOG_GFLAGS_TEST_CACHE_KEY  ~ /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include ~  ~ gflags_shared CACHE INTERNAL  )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(55):  message(STATUS Checking SFM glog/gflags deps... TRUE )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
-- Checking SFM glog/gflags deps... TRUE
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(57):  unset(__cache_key )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(58):  set(SFM_DEPS_OK TRUE )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(63):  if(NOT HAVE_EIGEN OR NOT SFM_DEPS_OK )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(78):  set(LIBMV_LIGHT_INCLUDES /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/src/libmv_light /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/include/opencv  /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/include )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(85):  set(LIBMV_LIGHT_LIBS correspondence multiview numeric  gflags_shared )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(93):  if(Ceres_FOUND )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(99):  else()
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(100):  add_definitions(-DCERES_FOUND=0 )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(101):  message(STATUS CERES support is disabled. Ceres Solver for reconstruction API is required. )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt(106):  ocv_add_module(sfm opencv_core opencv_calib3d opencv_features2d opencv_xfeatures2d opencv_imgcodecs WRAP python )
   Called from: [1]     /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/contrib/modules/sfm/CMakeLists.txt
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/git/cmake/OpenCVModule.cmake(125):  ocv_debug_message(ocv_add_module( sfm opencv_core;opencv_calib3d;opencv_features2d;opencv_xfeatures2d;opencv_imgcodecs;WRAP;python ) )

If I leave cnn_3dobj enabled and add this mapping then it builds OK. Will update this PR with this mapping.

BTW, Looks like there are no more places in OpenCV where is defined or used Glog_LIBS (except cnn_3dobj which is broken and disabled), so current patch looks strange.

I was testing this in cross compilation with OpenEmbedded with a recipe based on 4.5.2 (not latest master), in case I've missed some other important change to completely disable cnn_3dobj)

@alalek
Copy link
Member

alalek commented Apr 16, 2021

BTW, To unblock builds you can disable "sfm" module. Without Ceres most of sfm functionality is not available anyway.
Use cmake -DBUILD_opencv_sfm=OFF ...


The file was found at
/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake

What is defined by this file? How was Glog build?
Could you archive to .zip the directory /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/ and then attach that .zip file?


cnn_3dobj is dead module. It will be removed in the next major update (5.0).

@shr-project
Copy link
Author

shr-project commented Apr 16, 2021

BTW, To unblock builds you can disable "sfm" module. Without Ceres most of sfm functionality is not available anyway.
Use cmake -DBUILD_opencv_sfm=OFF ...

Builds are already unblocked by the previous version of this PR which got merged in:
https://git.openembedded.org/meta-openembedded/commit/?id=41ca2e57bc2e00ca8db577c6e311ab2e8f39b7aa

What is defined by this file? How was Glog build?

Glog was built by this recipe:
https://git.openembedded.org/meta-openembedded/tree/meta-oe/recipes-support/glog/glog_0.4.0.bb

Could you archive to .zip the directory /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/opencv/4.5.2-r0/recipe-sysroot/usr/lib/cmake/glog/ and then attach that .zip file?

sure:
glog.tar.gz

@alalek
Copy link
Member

alalek commented Apr 17, 2021

glog.tar.gz

Thank you!
These scripts don't define _INCLUDE_DIRS / _LIBRARIES variables anymore. Only "glog::glog" target is defined.

Please try this patch:

 if(NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR)
   set(GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR}")
 endif()
+if(NOT GLOG_LIBRARIES AND TARGET glog::glog)
+  set(GLOG_LIBRARIES glog::glog)
+endif()

Similar patch for gflags (if needed):

 if(NOT DEFINED GFLAGS_INCLUDE_DIRS AND DEFINED GFLAGS_INCLUDE_DIR)
   set(GFLAGS_INCLUDE_DIRS "${GFLAGS_INCLUDE_DIR}")
 endif()
+if(NOT GFLAGS_LIBRARIES AND TARGET gflags::gflags)
+  set(GFLAGS_LIBRARIES gflags::gflags)
+endif()

I created PR with fixes here (to 3.4 branch): #2928


In case of issues please add this statement to dump related CMake vars:

ocv_cmake_dump_vars("glog")

(BTW, don't use that with --trace / --trace-expand due to huge output)

@shr-project
Copy link
Author

Replaced with #2928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants