我想将tesseract与qt 5 + mingw一起使用。我从这里下载了 vc++ 库冷杉
在我的申请中,我做到了:
#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 += $$PWDtesseract-3.02.02-win32-lib-include-dirsinclude
LIBS += -L$$PWDtesseract-3.02.02-win32-lib-include-dirslib -llibtesseract302-static-debug
LIBS += -L$$PWDleptonicalib -lliblept
SOURCES += main.cpp
dialog.cpp
HEADERS += dialog.h
FORMS += dialog.ui
我花了很多时间试图链接这个,我做错了什么吗?
我确实设法用 mingw 编译了 tesseract,但在我尝试将其与我的测试应用程序链接后,我得到了很多:
tesseract-ocrccutiltprintf.cpp:56: ошибка: undefined reference to `_Unwind_Resume'
和
pageiterator.cpp:-1: ошибка: undefined reference to `__gxx_personality_v0'
错误。这是什么意思?这次在我的专业文件中,我确实添加了
LIBS += -L$$PWDlib -llept -ltesseract -ltiff -lwebp -lgif -lpng -ljpeg -lzlib125-static-mtdll-debug
LIBS += lws2_32