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 869 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.
  • DQUY05D DQUY05

    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 !

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on 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

    DQUY05D 1 Reply Last reply
    0
    • jsulmJ jsulm

      @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.

      DQUY05D Offline
      DQUY05D Offline
      DQUY05
      wrote on 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

      jsulmJ 1 Reply Last reply
      0
      • DQUY05D DQUY05

        @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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #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

        DQUY05D 1 Reply Last reply
        0
        • jsulmJ jsulm

          @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.

          DQUY05D Offline
          DQUY05D Offline
          DQUY05
          wrote on 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!

          jsulmJ 1 Reply Last reply
          0
          • DQUY05D DQUY05

            @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!

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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

            DQUY05D 1 Reply Last reply
            0
            • jsulmJ jsulm

              @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.

              DQUY05D Offline
              DQUY05D Offline
              DQUY05
              wrote on 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
              
              jsulmJ 1 Reply Last reply
              0
              • DQUY05D DQUY05

                @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
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by jsulm
                #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

                DQUY05D 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @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
                  
                  DQUY05D Offline
                  DQUY05D Offline
                  DQUY05
                  wrote on 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
                  • DQUY05D Offline
                    DQUY05D Offline
                    DQUY05
                    wrote on 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,

                    jsulmJ 1 Reply Last reply
                    0
                    • DQUY05D DQUY05

                      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,

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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