Tesseract libraries on Qt 5.7 Mingw32 in Windows

  • Hi, i'm trying to build the tesseract ocr libraries in order to use these on qt 5.7. I've found only this link tutorial but when i try to launch, at the end, the code qt says me that:

    Starting C:\Users\fed_2\Documents\build-Prova_tsr-Desktop_Qt_5_7_1_MinGW_32bit-Debug\debug\Interfaccia.exe...
    The program has unexpectedly finished.
    C:\Users\fed_2\Documents\build-Prova_tsr-Desktop_Qt_5_7_1_MinGW_32bit-Debug\debug\Interfaccia.exe crashed.

    has anyone ever used these libraries on QT and is able to explain how to install correctly?

    Thank you

  • Lifetime Qt Champion


    Can you show a stack trace ?

    By the way, where are the Tesseract .dlls located ?

    Depending on that, you should modify the PATH environment variable in the Run part of the Project panel to contain also the folder to them.

  • All the libraries are built following the tutorial in the link that i show in the main post.
    The .pro file is that:

    SOURCES += main.cpp\
     LIBS +=-LC:\\new\\lib \
    -lopencv_calib3d320d \

    and the main file

    #include <tesseract/baseapi.h>
    #include <tesseract/strngs.h>
    #include <iostream>
    int main(int argc, char** argv)
    const char* lang = "eng";
    const char* filename = "C:/immagini/nn.jpg";
    tesseract::TessBaseAPI tess;
    tess.Init(NULL, lang, tesseract::OEM_DEFAULT);
    FILE* fin = fopen(filename, "rb");
    if (fin == NULL)
    std::cout << "Cannot open " << filename << std::endl;
    return -1;
    STRING text;
    if (!tess.ProcessPages(filename, NULL, 0, &text))
    std::cout << "Error during processing." << std::endl;
    return -1;
    std::cout << text.string() << std::endl;
    return 0;

  • Lifetime Qt Champion

    But you likely have a runtime problem hence my question of location of the .dlls. Did you modify the PATH environment variable in Qt Creator like I suggested ? Otherwise your application won't find the tesseract nor the OpenCV .dlls file thus it won't be able to start.

    Note that your tesseract link lines look wrong, they should be like the OpenCV ones.

  • Yes i've
    I checked the PATH environment and the path is there. The .pro file works for the opencv libraries but when it calls the "tesseract::TessBaseAPI tess" that line it crashed.

  • Lifetime Qt Champion

    What does the stack trace tells you about that ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.