I want to use tesseract api on my project. And the problem is I can't compile my test code that look like this.
#include <iostream>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
int main()
{
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
api->End();
delete api;
return 0;
}
I'm using this
g++ -L/Projects/cpp/CPE1/Project/lib/ -ltesseract50 -lleptonica -I/Projects/cpp/CPE1/Project/include t.cpp -o t
and got
C:\Users\MSINOT~1\AppData\Local\Temp\cc4xWMfF.o:t.cpp:(.text+0x21): undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
C:\Users\MSINOT~1\AppData\Local\Temp\cc4xWMfF.o:t.cpp:(.text+0x44): undefined reference to `tesseract::TessBaseAPI::End()'
collect2.exe: error: ld returned 1 exit status
my folder structure looks like this (this is all on drive D:)
\---Project
+---bin
+---cmake
+---include
| +---leptonica
| \---tesseract
+---leptonica-1.80.0
+---lib
| +---cmake
| \---pkgconfig
+---tesseract-master
\---Uics
[my code is here]
I compiled leptonica and tesseract following this https://tesseract-ocr.github.io/tessdoc/Compiling.html#windows on "Develop Tesseract" and specify install path to my project folder.
I'm a noob in this type of problem, so if you have completely different ways to use tesseract API pls tell me.
g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Tesseract from main branch https://github.com/tesseract-ocr/tesseract
Leptonica from 1.80.0 release https://github.com/DanBloomberg/leptonica
cmake version 3.19.4
*edit add lib folder listing
D:\PROJECTS\CPP\CPE1\PROJECT\LIB
| leptonica.lib
| tesseract50.lib
|
+---cmake
| +---leptonica
| | LeptonicaConfig-version.cmake
| | LeptonicaConfig.cmake
| | LeptonicaTargets-release.cmake
| | LeptonicaTargets.cmake
| |
| \---tesseract
| TesseractConfig.cmake
| TesseractConfigVersion.cmake
| TesseractTargets-release.cmake
| TesseractTargets.cmake
|
\---pkgconfig
lept.pc
tesseract.pc