Reputation: 2348
I have a basic empty Qt 5.8 project, and I want to integrate Tesseract library to work with that. I can't find any full step-by-step instructions how to do that, so I hope someone can share an experience.
I want to use something like that in my code:
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
I know that I need to put some additional instructions to the .pro file (etc LIBS, HEADERS), but I don't know is there is any right way to do that.
Qt 5.8
Windows 10
MinGW 32bit
Upvotes: 4
Views: 5012
Reputation: 71
Ubuntu and MacOS
a good toturial can be found here and add these lines in .pro for Ubuntu:
INCLUDEPATH += /usr/local/include/tesseract
INCLUDEPATH += /usr/local/include/leptonica
LIBS += -ltesseract -llept
Windows
You should compile tesseract project and full step-by-step instructions can be found here
win32:CONFIG(release, debug|release): LIBS += -L'C:/Program Files/tesseract/lib/' -ltesseract50
else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files/tesseract/lib/' -ltesseract50d
INCLUDEPATH += 'C:/Program Files/tesseract/include'
Upvotes: 1
Reputation: 856
I have done this once in a project that also uses OpenCV, before Tesseract was in its stable branch. This allowed me to leave out all image reading libraries since I would do that through OpenCV. I ended up compiling Tesseract through Cygwin, but that gave me binary compatible libs to use in my MinGW32 project.
I followed http://vorba.ch/2014/tesseract-cygwin.html for the most part. I configured Leptonica 1.72 as such:
./configure --without-giflib --without-zlib --without-libpng --without-jpeg --without-libtiff --without-libwebp --without-libopenjpeg
If you compile leptonica under cygwin there must not be any spaces in the source path or you will get stray '\' errors.
To compile tesseract itself you will find MinGW does not provide strtok_r.h. However, Tesseract includes a version of strtok_r.cpp, so the easiest fix is to edit ambigs.cpp and replace #include "strtok_r.h" with the function signature:
char *strtok_r(char *s, const char * sep, char ** p);
MinGW has a bug in math.h regarding the _hypot function. Replacing it with hypot (without the underscore) fixes this issue.
This is everything I documented for myself at the time. If you have any trouble let me know so I can see if I forgot to include anything.
Upvotes: 1
Reputation: 49289
The "with Qt" part is redundant, you don't really need to do anything "with Qt" in order to use a generic library.
The library will need to be build using preferably the same, or at the very least, binary compatible compiler. The actual build instructions can be found here.
As for the Qt PRO file, you can simply use the wizard from Creator - click the project name in the left side bar (the project tree) and "Add Library" and follow the wizard depending on type of lib you are using.
It will generate the necessary project definitions in the following format:
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/release/ -lmylib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../projects/mylib/debug/ -lmylib
else:unix: LIBS += -L$$OUT_PWD/../../../projects/mylib/ -lmylib
INCLUDEPATH += $$PWD/../../../projects/mylib
DEPENDPATH += $$PWD/../../../projects/mylib
win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/release/mylib.lib
else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/debug/mylib.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/libmylib.a
Upvotes: 2