On Thu, Mar 29, 2012 at 11:23 PM, zdenko podobny <zde...@gmail.com> wrote:

>
>
> On Thu, Mar 29, 2012 at 4:52 PM, Gustavo Souto <ghso...@gmail.com> wrote:
>
>> Hi everyone, I need you help...
>>
>>   I want to create a program in C++ with Tesseract, but when I try to
>> compile the source code some errors appear. I don't know well how to link
>> the libs to the source code, but I did do like this:
>> ------------------------------------  CODE
>> ---------------------------------------------------------------
>>
>> #include <baseapi.h>
>> #include <allheaders.h>
>> #include <iostream>
>> #include <opencv/cv.h>
>> #include <opencv/highgui.h>
>>
>> using namespace std;
>>
>> int main() {
>>
>>     tesseract::TessBaseAPI tess;
>>
>>     tess.Init(NULL, "eng", tesseract::OEM_DEFAULT);
>>     cv::Mat image = cv::imread("/home/souto3/Pictures/num.tif");
>>     tess.SetImage((uchar*)image.data, image.size().width, 
>> image.size().height, image.channels(), image.step1());
>>     tess.Recognize(0);
>>     const char* out = tess.GetUTF8Text();
>>
>>     cout << out;
>>
>>     return 0;
>> }
>> ------------------------------ END CODE -------------------
>>
>> -------------------- ERROR --------------------------------
>> /tmp/ccAUGhHc.o: In function `main':
>> main.cpp:(.text+0x1b): undefined reference to 
>> `tesseract::TessBaseAPI::TessBaseAPI()'
>> main.cpp:(.text+0x75): undefined reference to 
>> `cv::imread(std::basic_string<char, std::char_traits<char>, 
>> std::allocator<char> > const&, int)'
>> main.cpp:(.text+0x101): undefined reference to 
>> `tesseract::TessBaseAPI::SetImage(unsigned char const*, int, int, int, int)'
>> main.cpp:(.text+0x115): undefined reference to 
>> `tesseract::TessBaseAPI::Recognize(ETEXT_DESC*)'
>> main.cpp:(.text+0x124): undefined reference to 
>> `tesseract::TessBaseAPI::GetUTF8Text()'
>> main.cpp:(.text+0x15c): undefined reference to 
>> `tesseract::TessBaseAPI::~TessBaseAPI()'
>> main.cpp:(.text+0x1c8): undefined reference to 
>> `tesseract::TessBaseAPI::~TessBaseAPI()'
>> /tmp/ccAUGhHc.o: In function `tesseract::TessBaseAPI::Init(char const*, char 
>> const*, tesseract::OcrEngineMode)':
>> main.cpp:(.text._ZN9tesseract11TessBaseAPI4InitEPKcS2_NS_13OcrEngineModeE[tesseract::TessBaseAPI::Init(char
>>  const*, char const*, tesseract::OcrEngineMode)]+0x4f): undefined reference 
>> to `tesseract::TessBaseAPI::Init(char const*, char const*, 
>> tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, 
>> GenericVector<STRING> const*, bool)'
>> /tmp/ccAUGhHc.o: In function `cv::Mat::release()':
>> main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x4b): undefined 
>> reference to `cv::fastFree(void*)'
>> ------------------------ END ERROR 
>> ----------------------------------------------------------------------
>>
>> You did not mentioned how you try to compile file (neither which version
> of tesseract you use). But I guess you forget to link to tesseract library
> (-ltesseract).
>
> Zdenko
>

And using leptonica's pixRead() function to read images is easier (see the
source for tesseractmain.cpp for an example [1]) .

[1]
http://code.google.com/p/tesseract-ocr/source/browse/trunk/api/tesseractmain.cpp#148

-- 
You received this message because you are subscribed to the Google
Groups "tesseract-ocr" group.
To post to this group, send email to tesseract-ocr@googlegroups.com
To unsubscribe from this group, send email to
tesseract-ocr+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en

Reply via email to