Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Static Qt with OpenCV
Forum Updated to NodeBB v4.3 + New Features

Static Qt with OpenCV

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 183 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pouriya
    wrote on 3 Jun 2024, 10:01 last edited by Pouriya 6 Mar 2024, 10:03
    #1

    I've configured Qt 5.15.13 with below parameters:

    configure.bat -static -release -platform win32-g++ -opensource -confirm-license -qt-zlib -qt-libpng -qt-webp -qt-libjpeg -qt-freetype -no-xcb -no-opengl -skip qtdoc -skip qtscxml -skip qtwebchannel -skip qtxmlpatterns -skip qt3d -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtlottie -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtremoteobjects -skip qtscript -skip qtspeech -skip qtsvg -skip qtwayland -skip qtwebglplugin -skip qtwebview -skip webengine -skip qtvirtualkeyboard -make libs -nomake tools -nomake examples -nomake tests
    

    and built it via mingw 11.2.0 x64 on Windows 10.
    The build procedure finished with no error and qt installed successfully

    I've also built two versions of opencv, one with BUILD_SHARED_LIBS=OFF and the other with BUILD_SHARED_LIBS=ON parameter by means of the same compiler.

    When I add the dynamic build of opencv with qt, everything is fine, but when I use the static build of opencv I get these errors:

    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images9grabFrameEv+0x152): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv20CvVideoWriter_Images4openEPKc+0x150): undefined reference to `cv::haveImageWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x5a4): undefined reference to `cv::haveImageReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa5c): undefined reference to `cv::haveImageReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv20CvVideoWriter_Images10writeFrameEPK9_IplImage+0x152): undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
    C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_mjpeg_decoder.cpp.obj):cap_mjpeg_decoder.cpp:(.text$_ZN2cv17MotionJpegCapture13retrieveFrameEiRKNS_12_OutputArrayE+0x92): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[1]: *** [Makefile.Release:74: release/videosender.exe] Error 1
    

    This is the .pro file of the project:

    4.png

    Is there any solution for this problem?

    J 1 Reply Last reply 3 Jun 2024, 12:03
    0
    • P Pouriya
      3 Jun 2024, 10:01

      I've configured Qt 5.15.13 with below parameters:

      configure.bat -static -release -platform win32-g++ -opensource -confirm-license -qt-zlib -qt-libpng -qt-webp -qt-libjpeg -qt-freetype -no-xcb -no-opengl -skip qtdoc -skip qtscxml -skip qtwebchannel -skip qtxmlpatterns -skip qt3d -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtlottie -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtremoteobjects -skip qtscript -skip qtspeech -skip qtsvg -skip qtwayland -skip qtwebglplugin -skip qtwebview -skip webengine -skip qtvirtualkeyboard -make libs -nomake tools -nomake examples -nomake tests
      

      and built it via mingw 11.2.0 x64 on Windows 10.
      The build procedure finished with no error and qt installed successfully

      I've also built two versions of opencv, one with BUILD_SHARED_LIBS=OFF and the other with BUILD_SHARED_LIBS=ON parameter by means of the same compiler.

      When I add the dynamic build of opencv with qt, everything is fine, but when I use the static build of opencv I get these errors:

      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images9grabFrameEv+0x152): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv20CvVideoWriter_Images4openEPKc+0x150): undefined reference to `cv::haveImageWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x5a4): undefined reference to `cv::haveImageReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv16CvCapture_Images4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xa5c): undefined reference to `cv::haveImageReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_images.cpp.obj):cap_images.cpp:(.text$_ZN2cv20CvVideoWriter_Images10writeFrameEPK9_IplImage+0x152): undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
      C:/Qt/Qt6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\OpenCV490\opencv\release_static\lib\libopencv_videoio490.a(cap_mjpeg_decoder.cpp.obj):cap_mjpeg_decoder.cpp:(.text$_ZN2cv17MotionJpegCapture13retrieveFrameEiRKNS_12_OutputArrayE+0x92): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
      collect2.exe: error: ld returned 1 exit status
      mingw32-make[1]: *** [Makefile.Release:74: release/videosender.exe] Error 1
      

      This is the .pro file of the project:

      4.png

      Is there any solution for this problem?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 Jun 2024, 12:03 last edited by
      #2

      @Pouriya I think you need to fix the order in which you add the static libs. For example calib3d490 lib apparently depends on core490 lib.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4

      1/2

      3 Jun 2024, 10:01

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved