Qt和tesseract

时间:2013-10-19 16:06:06

标签: c++ qt tesseract leptonica

我想使用qt 5 + mingw的tesseract。我从here

下载了vc ++ libs fir

在我的申请中我做了:

#include "tesseract/baseapi.h"


...


tesseract::TessBaseAPI *OCRbase =  new tesseract::TessBaseAPI();

if (!OCRbase->Init(NULL,"eng",tesseract::OEM_DEFAULT))
{
    qDebug() << "tesseract init error";
    return;
}

但是这段代码给了我这样的错误:

testOCR/dialog.cpp:57: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
debug/dialog.o: In function `ZN9tesseract11TessBaseAPI4InitEPKcS2_NS_13OcrEngineModeE':
testOCR/tesseract-3.02.02-win32-lib-include-dirs/include/tesseract/baseapi.h:208:   undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool)'
collect2.exe: error: ld returned 1 exit status

我的.pro文件如下所示:

INCLUDEPATH += $$PWD\tesseract-3.02.02-win32-lib-include-dirs\include
LIBS += -L$$PWD\tesseract-3.02.02-win32-lib-include-dirs\lib -llibtesseract302-static-debug
LIBS += -L$$PWD\leptonica\lib -lliblept

SOURCES += main.cpp\
        dialog.cpp

HEADERS  += dialog.h

FORMS    += dialog.ui

我花了很多时间试图链接这个,是不是我做错了?

1 个答案:

答案 0 :(得分:0)

我确实设法用mingw自己编译tesseract但是在我尝试将它与我的测试应用程序链接之后我得到了很多:

tesseract-ocr\ccutil\tprintf.cpp:56: ошибка: undefined reference to `_Unwind_Resume'

pageiterator.cpp:-1: ошибка: undefined reference to `__gxx_personality_v0'

错误。这意味着什么?在我的专业档案这次我添加了

LIBS    += -L$$PWD\lib -llept -ltesseract -ltiff -lwebp -lgif -lpng -ljpeg -lzlib125-static-mtdll-debug
LIBS    += lws2_32