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. qt creator tesseract ocr problem
QtWS25 Last Chance

qt creator tesseract ocr problem

Scheduled Pinned Locked Moved Solved Installation and Deployment
7 Posts 3 Posters 402 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.
  • K Offline
    K Offline
    Kenengan
    wrote on last edited by
    #1

    Hi, I have some problem with qt creatore. When i make qwidgetapp in visual studio 2019 using qt visual studio tools and i add tesseract/leptonica installed from vcpkg here, then everything wokrs all right (its all dynamic linking via dlls). But in qt creator i cannot add packages from vcpkg.. When I for example add to code:

    #include <tesseract/baseapi.h>
    #include <leptonica/allheaders.h>
    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
    

    and I have in qmake this:

    INCLUDEPATH += "D:\vcpkg\installed\x64-windows\include"
    

    then qt creator see header files and if i type for example api->init it see all methods etc.

    But when i try run program i have all the time this error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()".

    I tried adding lib files with LIBS +=, I also tried copy dll files to folder where executable will be created but nothing work.

    Any sugestions what else i can try?

    JonBJ 1 Reply Last reply
    0
    • K Kenengan

      Hi, I have some problem with qt creatore. When i make qwidgetapp in visual studio 2019 using qt visual studio tools and i add tesseract/leptonica installed from vcpkg here, then everything wokrs all right (its all dynamic linking via dlls). But in qt creator i cannot add packages from vcpkg.. When I for example add to code:

      #include <tesseract/baseapi.h>
      #include <leptonica/allheaders.h>
      tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
      

      and I have in qmake this:

      INCLUDEPATH += "D:\vcpkg\installed\x64-windows\include"
      

      then qt creator see header files and if i type for example api->init it see all methods etc.

      But when i try run program i have all the time this error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()".

      I tried adding lib files with LIBS +=, I also tried copy dll files to folder where executable will be created but nothing work.

      Any sugestions what else i can try?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Kenengan said in qt creator tesseract ocr problem:

      But when i try run program

      When you run the program? Do you mean when you try to link it? Please be clear.

      I tried adding lib files with LIBS +=,

      Show this.

      Have a read through:
      https://stackoverflow.com/questions/25044448/undefined-reference-to-tesseracttessbaseapitessbaseapi
      https://forum.qt.io/topic/137482/qt-undefined-reference-to-tesseract-tessbaseapi-tessbaseapi

      1 Reply Last reply
      1
      • K Offline
        K Offline
        Kenengan
        wrote on last edited by
        #3

        By "when i try run program" I mean I run this in debug mode (ctrl + r).
        Here is full code, very simple console app, main.cpp:

        #include <QCoreApplication>
        #include <tesseract/baseapi.h>
        #include <leptonica/allheaders.h>
        
        int main(int argc, char *argv[])
        {
            QCoreApplication a(argc, argv);
        
            tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
        
            return a.exec();
        }
        

        and here is .pro file:

        QT = core
        
        CONFIG += c++17 cmdline
        
        # You can make your code fail to compile if it uses deprecated APIs.
        # In order to do so, uncomment the following line.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        SOURCES += \
                main.cpp
        
        # Default rules for deployment.
        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /opt/$${TARGET}/bin
        !isEmpty(target.path): INSTALLS += target
        
        INCLUDEPATH += "D:\vcpkg\installed\x64-windows\include"
        LIBS += -L"D:\vcpkg\installed\x64-windows\debug\lib"
        LIBS += -L"D:\vcpkg\installed\x64-windows\debug\bin"
        LIBS += -ltesseract55d -lleptonica-1.84.1d
        

        It looks like includepath works just fine but libs+= not work and I dont know why. I also tried diffrent slashes like this "" and this "/", I tried copy lib and dll files to folder with source code (where main.cpp is located) and libs+= them directly, I also tried some others things that I found on internet but there is still same error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'".

        JonBJ 2 Replies Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Are you sure that:

          • you are linking to the correct libraries ?
          • these libraries are of the correct architecture ?
          • the compiler used for these libraries is the same as for your application ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • K Kenengan

            By "when i try run program" I mean I run this in debug mode (ctrl + r).
            Here is full code, very simple console app, main.cpp:

            #include <QCoreApplication>
            #include <tesseract/baseapi.h>
            #include <leptonica/allheaders.h>
            
            int main(int argc, char *argv[])
            {
                QCoreApplication a(argc, argv);
            
                tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
            
                return a.exec();
            }
            

            and here is .pro file:

            QT = core
            
            CONFIG += c++17 cmdline
            
            # You can make your code fail to compile if it uses deprecated APIs.
            # In order to do so, uncomment the following line.
            #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
            
            SOURCES += \
                    main.cpp
            
            # Default rules for deployment.
            qnx: target.path = /tmp/$${TARGET}/bin
            else: unix:!android: target.path = /opt/$${TARGET}/bin
            !isEmpty(target.path): INSTALLS += target
            
            INCLUDEPATH += "D:\vcpkg\installed\x64-windows\include"
            LIBS += -L"D:\vcpkg\installed\x64-windows\debug\lib"
            LIBS += -L"D:\vcpkg\installed\x64-windows\debug\bin"
            LIBS += -ltesseract55d -lleptonica-1.84.1d
            

            It looks like includepath works just fine but libs+= not work and I dont know why. I also tried diffrent slashes like this "" and this "/", I tried copy lib and dll files to folder with source code (where main.cpp is located) and libs+= them directly, I also tried some others things that I found on internet but there is still same error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'".

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Kenengan said in qt creator tesseract ocr problem:

            By "when i try run program" I mean I run this in debug mode (ctrl + r).

            I am still not convinced that you are reporting a runtime error rather than a link time one. You are a C++ developer so you must know the difference. Do not use Ctrl+R/Run, as this will first try to compile and link and may report an error there --- since you don't show us the Output from Creator we do not know how far you got. First do a complete Rebuild and tell us whether that completes successfully or reports an error before you get as far as tyring to run. I am not a Windows or MSVC user, but so far as I know

            error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()".

            will come from the linker, I don't think you would such an error at runtime? Let's establish that first before analyzing any further,

            1 Reply Last reply
            1
            • K Kenengan

              By "when i try run program" I mean I run this in debug mode (ctrl + r).
              Here is full code, very simple console app, main.cpp:

              #include <QCoreApplication>
              #include <tesseract/baseapi.h>
              #include <leptonica/allheaders.h>
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication a(argc, argv);
              
                  tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
              
                  return a.exec();
              }
              

              and here is .pro file:

              QT = core
              
              CONFIG += c++17 cmdline
              
              # You can make your code fail to compile if it uses deprecated APIs.
              # In order to do so, uncomment the following line.
              #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
              
              SOURCES += \
                      main.cpp
              
              # Default rules for deployment.
              qnx: target.path = /tmp/$${TARGET}/bin
              else: unix:!android: target.path = /opt/$${TARGET}/bin
              !isEmpty(target.path): INSTALLS += target
              
              INCLUDEPATH += "D:\vcpkg\installed\x64-windows\include"
              LIBS += -L"D:\vcpkg\installed\x64-windows\debug\lib"
              LIBS += -L"D:\vcpkg\installed\x64-windows\debug\bin"
              LIBS += -ltesseract55d -lleptonica-1.84.1d
              

              It looks like includepath works just fine but libs+= not work and I dont know why. I also tried diffrent slashes like this "" and this "/", I tried copy lib and dll files to folder with source code (where main.cpp is located) and libs+= them directly, I also tried some others things that I found on internet but there is still same error: "undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'".

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Kenengan said in qt creator tesseract ocr problem:

              LIBS += -L"D:\vcpkg\installed\x64-windows\debug\lib"
              LIBS += -L"D:\vcpkg\installed\x64-windows\debug\bin"
              LIBS += -ltesseract55d -lleptonica-1.84.1d

              P.S.
              I am concerned by these lines. I do not use MSVC so cannot be sure about this. Using -L..., and in particular -l... certainly is correct for Linux/gcc or MinGW under Windows. However you say you are using MSVC, and its LINK linker. I didn't think that accepts -L or -l for libraries? I'm not sure about -L equivalent if you need it it (/LIBPATH?), and I thought libraries are supplied by a filename/path ending in .lib? So are you following instructions for MinGW/gcc rather than for MSVC? Or are these lines indeed correct (somehow) for MSVC?

              1 Reply Last reply
              1
              • K Offline
                K Offline
                Kenengan
                wrote on last edited by
                #7

                I found solution, the problem was - I make console app in qt creator with mingw compiler, but tesseract and leptonica was build by vcpkg with msvc compiler. When I try link them to console app then I got this error I post above.

                If I switch mingw in qt creator to msvc then these libs works all right. I also rebuild tesseract and leptonica with mingw and link them to console app also using mingw and it also work just fine.

                So it was my fault, I use another compiler to build app (mingw) and another to build libraries (msvc), but thanks for help, now everything works good and I can keep working on my application.

                1 Reply Last reply
                0
                • K Kenengan has marked this topic as solved on

                • Login

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