user3853511
user3853511

Reputation: 43

undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'

I am trying to do something with the tesseract c++ library but I get the following linker error(mingw32-g++):

undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'

I am using Code::Blocks as my IDE and have done the following steps to prepare my environment:

  1. Downloaded the sources and prepared my build folder as descripted at http://tesseract-ocr.googlecode.com/svn/trunk/vs2008/doc/setup.html

  2. Created a new Code::Blocks project

  3. Added all libraries included in the lib directory to the Project (Settings->Compiler Settings->Linker Setting->Link libraries->add)
  4. Added the three additional folders (include, include/tesseract, include/leptonica) to the search directory list (Settings->Compiler Settings->Search directorys->add)

Then I have written some code to test my configuration ...

#include <baseapi.h>
#include <allheaders.h>
#include <iostream>
using namespace std;

int main()
{
    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
    return 0;
} 

... and the above written linker error occurs.

I don´t know what I am doing wrong, hope that anybody have an idea.

Thanks a lot.

Upvotes: 2

Views: 4594

Answers (3)

user13053502
user13053502

Reputation: 1

In ubuntu, installing tesseract and leptonica:

sudo apt install tesseract-ocr

sudo apt install libtesseract-dev

(see:https://github.com/tesseract-ocr/tesseract/wiki)

Place the headers:

#include <tesseract/baseapi.h>

#include <leptonica/allheaders.h>

Compile:

g++ program.cpp -o program -llept -ltesseract

Upvotes: 0

akozlu
akozlu

Reputation: 111

You have to add the libraries under the Other Linker Flags in Build Settings.

Try adding -ltesseract and -lstdc++ and the paths to tesseract and leptonica libraries in the following convention: -L/usr/local/Cellar/tesseract/3.04.01_2/lib

Upvotes: 1

Ilyssis
Ilyssis

Reputation: 4949

I had to add all the C/C++ include paths:

..\tesseract_3.05\api
..\tesseract_3.05\ccmain
..\tesseract_3.05\ccutil
..\tesseract_3.05\ccstruct
..\tesseract_3.05\classify
..\tesseract_3.05\cube
..\tesseract_3.05\cutil
..\tesseract_3.05\dict
..\tesseract_3.05\neural_networks\runtime
..\tesseract_3.05\textord
..\tesseract_3.05\viewer
..\tesseract_3.05\opencl
..\tesseract_3.05\wordrec
..\leptonica\src
..\liblept

Also I added all the libraries:

giflib.lib
libjpeg.lib
liblept.lib
libpng.lib
libtesseract.lib
libtiff.lib
libwebp.lib
openjpeg.lib
zlib.lib

Upvotes: 0

Related Questions