Search code examples
c++qttesseractleptonica

Tesseract in QT


This is the first time I am asking a question here.

I want to use Tesseract API in QT. My idea was to design a programme using QT that would read aloud messages (QSpeech) from Telegram Desktop version (not that important).

Tesseract came across as a tool I needed so I tried to implement it. I wanted to use its API, but finally I ended up using QProcess to call Tesseract as a programme.

HERE'S THE PROBLEM.

After including tesseract and leptonica libraries to .pro file i get this:

(.qtversion[qt_version_tag]+0x0):-1: error: undefined reference to `qt_version_tag'

How to fix it?

  • I use QT 5_12_3

I included the libs.

INCLUDEPATH += "/usr/include"
LIBS += -L"/usr/local/lib" -ltesseract

INCLUDEPATH += "/usr/include"
LIBS += -L"/usr/lib/x86_64-linux-gnu" -llept

I downloaded QT from the official website. Tesseract API code is an example taken from the documentation. From the same documentation I followed instructions to download everything needed. As I mentioned before, if I compile a text file with the code sample, then it works fine. I just can't integrate it into QT.


Solution

  • Tesseract and Leptonica create pkg-config files, so you didn't have to manually add INCLUDEPATH or LIBS to your project, instead use

    QT_CONFIG -= no-pkg-config
    Config *= link_pkgconfig
    PKGCONFIG *= tesseract
    

    If it doesn't work for you, check whether the Tesseract is installed correctly (also check that you have tesseract.pc file in your system).