opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

Prompt for unresolved external symbols when compiling CVV modules

Open GengGode opened this issue 1 year ago • 3 comments

System Information

OpenCV version: 4.9.0 Operating System / Platform: Windows 10 Compiler & compiler version: VS 2022

Detailed description

输出-生成.txt image It seems that it is because there was no moc applied to the object of qt, and the file moc_xxx was not found in the compilation directory

view_controller.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __cdecl cvv::gui::CallTab::metaObject(void)const " (?metaObject@CallTab@gui@cvv@@UEBAPEBUQMetaObject@@XZ)
image_call_tab.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __cdecl cvv::gui::CallTab::metaObject(void)const " (?metaObject@CallTab@gui@cvv@@UEBAPEBUQMetaObject@@XZ)
view_controller.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __cdecl cvv::gui::CallTab::qt_metacast(char const *)" (?qt_metacast@CallTab@gui@cvv@@UEAAPEAXPEBD@Z)
image_call_tab.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __cdecl cvv::gui::CallTab::qt_metacast(char const *)" (?qt_metacast@CallTab@gui@cvv@@UEAAPEAXPEBD@Z)

Steps to reproduce

clone

git clone --branch 4.9.0 --depth 1 https://github.com/opencv/opencv.git   
git clone --branch 4.9.0 --depth 1 https://github.com/opencv/opencv_contrib.git

output

Cloning into 'opencv'...
remote: Enumerating objects: 8638, done.
remote: Counting objects: 100% (8638/8638), done.
remote: Compressing objects: 100% (7371/7371), done.
remote: Total 8638 (delta 1370), reused 4372 (delta 839), pack-reused 0
Receiving objects: 100% (8638/8638), 87.25 MiB | 8.61 MiB/s, done.
Resolving deltas: 100% (1370/1370), done.
Note: switching to 'dad8af6b17f8e60d7b95a1203a1b4d22f56574cf'.

Cloning into 'opencv_contrib'...
remote: Enumerating objects: 3798, done.
remote: Counting objects: 100% (3798/3798), done.
remote: Compressing objects: 100% (3189/3189), done.
remote: Total 3798 (delta 677), reused 2130 (delta 356), pack-reused 0
Receiving objects: 100% (3798/3798), 53.53 MiB | 9.08 MiB/s, done.
Resolving deltas: 100% (677/677), done.
Note: switching to 'c7602a8f74205e44389bd6a4e8d727d32e7e27b4'.

install qt 5.15.2 msvc2019 Install through the official QT installer

open cmake-gui image

Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
Detected processor: AMD64
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")
libjpeg-turbo: VERSION = 2.1.3, BUILD = opencv-4.9.0-libjpeg-turbo
libjpeg-turbo(SIMD): SIMD extensions disabled: could not find NASM compiler.  Performance will suffer.
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.9.0-openjp2-2.5.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
found Intel IPP (ICV version): 2021.11.0 [2021.11.0]
at: C:/Users/Public/dev/opencv/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2021.11.0
at: C:/Users/Public/dev/opencv/build/3rdparty/ippicv/ippicv_win/iw
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) 
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
freetype2:   NO
harfbuzz:    NO
Julia not found. Not compiling Julia Bindings. 
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Processing WORLD modules...
    module opencv_core...
Allocator metrics storage type: 'long long'
    module opencv_flann...
    module opencv_imgproc...
    module opencv_features2d...
    module opencv_imgcodecs...
imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
    module opencv_videoio...
    module opencv_calib3d...
    module opencv_cvv...
    module opencv_video...
    module opencv_xfeatures2d...
Processing WORLD modules... DONE
Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
Excluding from source files list: modules/imgproc/src/resize.lasx.cpp

General configuration for OpenCV 4.9.0 =====================================
  Version control:               4.9.0

  Extra modules:
    Location (extra):            C:/Users/Public/dev/opencv_contrib/modules
    Version control (extra):     4.9.0

  Platform:
    Timestamp:                   2024-01-24T08:00:00Z
    Host:                        Windows 10.0.22631 AMD64
    CMake:                       3.26.4
    CMake generator:             Visual Studio 17 2022
    CMake build tool:            C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe
    MSVC:                        1936
    Configuration:               Debug 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 (14 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 (3 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (28 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (3 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:                C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe  (ver 19.36.32535.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP  /O2 /Ob2 /DNDEBUG 
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP  /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /O2 /Ob2 /DNDEBUG 
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO 
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core cvv features2d flann imgcodecs imgproc video videoio world xfeatures2d
    Disabled:                    aruco bgsegm bioinspired ccalib datasets dnn dnn_objdetect dnn_superres dpm face fuzzy gapi hfs highgui img_hash intensity_transform java_bindings_generator js_bindings_generator line_descriptor mcc ml objc_bindings_generator objdetect optflow phase_unwrapping photo plot python_bindings_generator python_tests quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking videostab wechat_qrcode ximgproc xobjdetect xphoto
    Disabled by dependency:      -
    Unavailable:                 alphamat cannops cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev freetype hdf java julia matlab ovis python2 python3 sfm ts viz
    Applications:                -
    Documentation:               NO
    Non-free algorithms:         YES

  Windows RT support:            NO

  GUI: 
    QT:                          YES (ver 5.15.2 )
      QT OpenGL support:         NO
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.3)
    JPEG:                        build-libjpeg-turbo (ver 2.1.3-62)
      SIMD Support Request:      YES
      SIMD Support:              NO
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.2.0)
    JPEG 2000:                   build (ver 2.5.0)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.134.100)
      avformat:                  YES (58.76.100)
      avutil:                    YES (56.70.100)
      swscale:                   YES (5.9.100)
      avresample:                YES (4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            Concurrency

  Trace:                         YES (built-in)

  Other third-party libraries:
    Intel IPP:                   2021.11.0 [2021.11.0]
           at:                   C:/Users/Public/dev/opencv/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2021.11.0)
              at:                C:/Users/Public/dev/opencv/build/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.19.1)
    Flatbuffers:                 builtin/3rdparty (23.5.9)

  OpenCL:                        YES (NVD3D11)
    Include path:                C:/Users/Public/dev/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            NO

  Install to:                    C:/Users/Public/dev/opencv/build/install
-----------------------------------------------------------------

Configuring done (5.0s)
Generating done (1.0s)

Issue submission checklist

  • [X] I report the issue, it's not a question
  • [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • [X] I updated to the latest OpenCV version and the issue is still there
  • [ ] There is reproducer code and related data files (videos, images, onnx, etc)

GengGode avatar Jan 24 '24 03:01 GengGode

After manually executing moc on xxx.hpp.

image

Add moc_ xxx.cpp to the project.

image

Can solve the problem of symbol not being found in xxx.obj

image

You can see that the error message from main_call_window.obj has disappeared

输出-生成.txt

But I couldn't find a solution to fix it by setting up relevant code in CMake

GengGode avatar Jan 24 '24 14:01 GengGode

As long as the BUILD_opencv_world is not checked, it can be successfully built. I don't know if this is intentional or not

GengGode avatar Jan 24 '24 19:01 GengGode

I found that the reason is that qt needs to be AUTOMOC before target creation, but qt in cvv is only found in cvv's cmakelist. When compiling the opencv_world, the cmakelist in cvv was not run, so there are no qt and moc for the opencv_world.

As a result, I made some modifications in cmakelist in opencv_world, moc the source and header files of cvv in opencv_world(but I don't know why I can't set only the moc part of the file, so it now moc all the source and header files), and after the modifications, I compiled a opencv_world.dll file linked to qt.

After testing, it works very well

fix pr:https://github.com/opencv/opencv/pull/24921

image

GengGode avatar Jan 25 '24 08:01 GengGode