Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Run the application with Debug error with static library
Forum Updated to NodeBB v4.3 + New Features

Run the application with Debug error with static library

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
11 Posts 2 Posters 847 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.
  • D Offline
    D Offline
    DQUY05
    wrote on 4 Nov 2024, 04:17 last edited by
    #1

    Hi,

    I use Qt5.15 C++, for Tessaract application, I use static library, my .pro file :

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd
    
    INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
    DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
    
    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseract.a
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseractd.a
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseract.lib
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseractd.lib
    
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd
    
    INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
    DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
    

    but when running the program I get Debug error message, although I have run in Debug mode, can someone help me?

    b49f3a8d-6558-4ebb-b02e-e6b3e774787b-image.png

    Thanks !

    J 1 Reply Last reply 4 Nov 2024, 08:20
    0
    • D DQUY05
      4 Nov 2024, 04:17

      Hi,

      I use Qt5.15 C++, for Tessaract application, I use static library, my .pro file :

      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
      else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd
      
      INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
      DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
      
      win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseract.a
      else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseractd.a
      else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseract.lib
      else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseractd.lib
      
      
      win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept
      else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd
      
      INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
      DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
      

      but when running the program I get Debug error message, although I have run in Debug mode, can someone help me?

      b49f3a8d-6558-4ebb-b02e-e6b3e774787b-image.png

      Thanks !

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 4 Nov 2024, 08:20 last edited by
      #2

      @DQUY05 said in Run the application with Debug error with static library:

      -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract

      If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.

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

      D 1 Reply Last reply 4 Nov 2024, 13:08
      0
      • J jsulm
        4 Nov 2024, 08:20

        @DQUY05 said in Run the application with Debug error with static library:

        -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract

        If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.

        D Offline
        D Offline
        DQUY05
        wrote on 4 Nov 2024, 13:08 last edited by
        #3

        @jsulm said in Run the application with Debug error with static library:

        @DQUY05 said in Run the application with Debug error with static library:

        -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract

        If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.

        Thank Sir !

        When I switch to this option,

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd
        
        INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
        DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
        
        
        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd
        
        INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
        DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
        

        Then I got an error, I tried to find out but there is very little documentation about tesseract static library, can you help me see where the error is? Thanks!
        I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract

        afca0340-af88-4a76-bd19-388dd76e67eb-image.png

        J 1 Reply Last reply 4 Nov 2024, 13:29
        0
        • D DQUY05
          4 Nov 2024, 13:08

          @jsulm said in Run the application with Debug error with static library:

          @DQUY05 said in Run the application with Debug error with static library:

          -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract

          If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.

          Thank Sir !

          When I switch to this option,

          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd
          
          INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
          DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
          
          
          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept
          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd
          
          INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
          DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
          

          Then I got an error, I tried to find out but there is very little documentation about tesseract static library, can you help me see where the error is? Thanks!
          I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract

          afca0340-af88-4a76-bd19-388dd76e67eb-image.png

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 4 Nov 2024, 13:29 last edited by jsulm 11 Apr 2024, 13:30
          #4

          @DQUY05 said in Run the application with Debug error with static library:

          I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract

          OK, forget my previous post.
          The problem is that this static build does not contain debug versions of the libs (like libtesseractd.a).
          Try to change:

          -ltesseractd
          

          to

          -ltesseract
          

          And same for the other libs.

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

          D 1 Reply Last reply 4 Nov 2024, 13:42
          0
          • J jsulm
            4 Nov 2024, 13:29

            @DQUY05 said in Run the application with Debug error with static library:

            I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract

            OK, forget my previous post.
            The problem is that this static build does not contain debug versions of the libs (like libtesseractd.a).
            Try to change:

            -ltesseractd
            

            to

            -ltesseract
            

            And same for the other libs.

            D Offline
            D Offline
            DQUY05
            wrote on 4 Nov 2024, 13:42 last edited by
            #5

            @jsulm said in Run the application with Debug error with static library:

            Được rồi, quên bài đăng trước của tôi đi.
            Vấn đề là bản dựng tĩnh này không chứa phiên bản gỡ lỗi của libs (như libtesseractd.a).
            Hãy thử thay đổi:

            Dear Sir !
            I tried as you said, but it seems the problem is that the other path is missing the file?

            9cfce344-cbba-4431-b551-55e0d2f4eb6f-image.png

            I am a newbie, not proficient in installing libraries, I hope you can guide me, this project is very interesting to me, Thanks!

            J 1 Reply Last reply 4 Nov 2024, 13:47
            0
            • D DQUY05
              4 Nov 2024, 13:42

              @jsulm said in Run the application with Debug error with static library:

              Được rồi, quên bài đăng trước của tôi đi.
              Vấn đề là bản dựng tĩnh này không chứa phiên bản gỡ lỗi của libs (như libtesseractd.a).
              Hãy thử thay đổi:

              Dear Sir !
              I tried as you said, but it seems the problem is that the other path is missing the file?

              9cfce344-cbba-4431-b551-55e0d2f4eb6f-image.png

              I am a newbie, not proficient in installing libraries, I hope you can guide me, this project is very interesting to me, Thanks!

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 4 Nov 2024, 13:47 last edited by
              #6

              @DQUY05 After changing the pro file do a complete rebuild:

              • Delete build folder
              • Run qmake
              • build

              If you still get "undefined reference" errors it means that a library was not found. Look for the very first error message or warning. You can also post the build log so we can check what library was not found.

              The problem could be that Tesseract is written in C++ and you cannot mix debug and release binaries. In this case you will have to build Tesseract statically for debug and release by yourself.

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

              D 1 Reply Last reply 4 Nov 2024, 14:16
              0
              • J jsulm
                4 Nov 2024, 13:47

                @DQUY05 After changing the pro file do a complete rebuild:

                • Delete build folder
                • Run qmake
                • build

                If you still get "undefined reference" errors it means that a library was not found. Look for the very first error message or warning. You can also post the build log so we can check what library was not found.

                The problem could be that Tesseract is written in C++ and you cannot mix debug and release binaries. In this case you will have to build Tesseract statically for debug and release by yourself.

                D Offline
                D Offline
                DQUY05
                wrote on 4 Nov 2024, 14:16 last edited by
                #7

                @jsulm said in Run the application with Debug error with static library:

                Delete build folder
                Run qmake
                build

                I followed this sequence, but the error still appears,
                My account can't attach Log file, I'm still used to using static library and environment variable type library like OpenCv, besides I don't know other approach

                INCLUDEPATH += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/include
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll
                LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dll
                
                J 1 Reply Last reply 4 Nov 2024, 14:19
                0
                • D DQUY05
                  4 Nov 2024, 14:16

                  @jsulm said in Run the application with Debug error with static library:

                  Delete build folder
                  Run qmake
                  build

                  I followed this sequence, but the error still appears,
                  My account can't attach Log file, I'm still used to using static library and environment variable type library like OpenCv, besides I don't know other approach

                  INCLUDEPATH += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/include
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dll
                  
                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 4 Nov 2024, 14:19 last edited by jsulm 11 Apr 2024, 14:20
                  #8

                  @DQUY05 said in Run the application with Debug error with static library:

                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll
                  LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dll

                  This is all wrong. If you want static build why do you link DLLs?
                  And on Windows you do not link DLLs, you link *.lib files (like libopencv_objdetect452.lib). It should be like:

                  LIBS += -LC:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin -lopencv_core452
                  

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

                  D 1 Reply Last reply 4 Nov 2024, 14:27
                  0
                  • J jsulm
                    4 Nov 2024, 14:19

                    @DQUY05 said in Run the application with Debug error with static library:

                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll
                    LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dll

                    This is all wrong. If you want static build why do you link DLLs?
                    And on Windows you do not link DLLs, you link *.lib files (like libopencv_objdetect452.lib). It should be like:

                    LIBS += -LC:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin -lopencv_core452
                    
                    D Offline
                    D Offline
                    DQUY05
                    wrote on 4 Nov 2024, 14:27 last edited by
                    #9

                    @jsulm

                    If I only run Opencv without Tesseract, the application works normally, but when I use the additional tesseract static library, it causes the error as mentioned. Is it because I use 2 different library methods in the same project?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DQUY05
                      wrote on 5 Nov 2024, 13:50 last edited by
                      #10

                      Hi,
                      Now I run without any errors, until calling this function

                      tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
                      

                      Then the error appeared.

                      error: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
                      

                      Is there something wrong with the static library add operation, I'm really confused,

                      J 1 Reply Last reply 5 Nov 2024, 14:37
                      0
                      • D DQUY05
                        5 Nov 2024, 13:50

                        Hi,
                        Now I run without any errors, until calling this function

                        tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
                        

                        Then the error appeared.

                        error: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
                        

                        Is there something wrong with the static library add operation, I'm really confused,

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 5 Nov 2024, 14:37 last edited by
                        #11

                        @DQUY05 said in Run the application with Debug error with static library:

                        Is there something wrong with the static library add operation

                        You're not linking the library which contains tesseract::TessBaseAPI.
                        Check the build log for warnings about incompatible library.

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

                        1 Reply Last reply
                        0

                        1/11

                        4 Nov 2024, 04:17

                        • Login

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