Re: How to build the tesseract 3.02.02 project in Eclipse at Ubuntu?

1,031 views
Skip to first unread message

zdenko podobny

unread,
Nov 16, 2012, 3:47:16 PM11/16/12
to tesser...@googlegroups.com
On Fri, Nov 16, 2012 at 3:03 AM, Linda Li <codingpo...@gmail.com> wrote:
I want to build the tesseract 3.02.02 project so that I can modify some code to tune it to some specific task.

Version: tesseract 3.02.02
Ubuntu 12.04, Eclipse Juno

I put the tesseract into the Eclipse project.

Include directories
/usr/local/include
/usr/local
/usr/include/leptonica
and all file directories of the tesseract source, e.g. /Tesseract302Test/src/api, etc.

Library Paths:
/usr/local/lib

Libraries
/lept

Then I build the project.

The error pops out:
../src/training/classifier_tester.cpp:20:35: fatal error: base/commandlineflags.h: No such file or directory
compilation terminated.

There is no such commandlineflags.h file.

If you would have a look at source, you could see that commandlineflags.h is part of conditional inclusion.

How can I solve this problem?
 
Define identifier USE_STD_NAMESPACE.

I search online a lot and fail to find an example. Most articles focus on compile tesseract to a library.

Thanks a lot in advance.

This is my first time to post the message on the group tesseract-ocr. Actually yesterday I tried to post the same message on tesseract-dev, but not succeed.
If it happens to appear on tesseract-dev at some point of later time, sorry for that. I just do not want to wait for too long.

You need to wait until moderator allows you to post to the list ;-)
 
--
Zdenko

zdenko podobny

unread,
Nov 18, 2012, 12:06:01 PM11/18/12
to tesser...@googlegroups.com
You should give definition to compiler. Have a look how it is done with autotools (or VC++ solution if you are familiar with it).

I am not eclipse user (even I tried once to open and compile tesseract project in it. It was smooth as far as I remember) but I would expect that eclipse is able to import autotools project...

-- 
Zdenko


On Sun, Nov 18, 2012 at 1:48 AM, Linda Li <codingpo...@gmail.com> wrote:
Thanks.

Then where should I put
#define USE_STD_NAMESPACE?

I put it in the tesseractmain.h, but the same error appears: fatal error: base/commandlineflags.h: No such file or directory

Sorry if my question is dumb.
Thanks.

On Friday, November 16, 2012 2:47:50 PM UTC-6, zdenop wrote:
On Fri, Nov 16, 2012 at 3:03 AM, Linda Li <codingpo...@gmail.com> wrote:

There is no such commandlineflags.h file.

If you would have a look at source, you could see that commandlineflags.h is part of conditional inclusion.

How can I solve this problem?
 
Define identifier USE_STD_NAMESPACE.
 
--
Zdenko

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

zdenko podobny

unread,
Nov 19, 2012, 11:29:31 AM11/19/12
to tesser...@googlegroups.com
On Sun, Nov 18, 2012 at 11:49 PM, Linda Li <codingpo...@gmail.com> wrote:

I build it to run tessearctmain.cpp.

I do not intend to compile the whole


Thanks to instruction from Zdenko, I add the symbols as follows:

In Eclipse, Project Properties->C/C++ General->Paths and Symbols

Symbol, Value.

USE_STD_NAMESPACE

VERSION=\"3.02.02\"


Now building succeeds.

Compile has errors, complaining there are several main() functions.

I have little knowledge of makefile, which I guess can circumvent this problem, so I renamed all functions with main(), except tesseractmain.cpp, to .txt files.


Are you sure you know what are you doing? 

Now the compiling errors are:

svutil.cpp:129: undefined reference to `sem_init'

svutil.cpp:137: undefined reference to `sem_post'

svutil.cpp:145: undefined reference to `sem_wait'

svutil.cpp:188: undefined reference to `pthread_create'


I search the word “sem_init”, which is in the configure file.

I do not understand the configure file.

Finding some commands containing “sem_init”

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5

char sem_init ();

int

main ()

{

return sem_init ();

;

return 0;

}


Google, found http://code.google.com/p/tesseract-ocr/issues/detail?id=757

The build fails as sem_init is in librt on Solaris. The attached patch adds searching for sem_init in librt. After that the build succeeds.”


Search librt in the libraries:

/usr/lib/x86_64-linux-gnu/

librt.a

librt.so


So I include /usr/lib/x86_64-linux-gnu into the Library Paths

Include rt into Libraries.


Rebuild the project with hope....


Again, the same compiling errors are:

svutil.cpp:129: undefined reference to `sem_init'

svutil.cpp:137: undefined reference to `sem_post'

svutil.cpp:145: undefined reference to `sem_wait'

svutil.cpp:188: undefined reference to `pthread_create'

I guess I need to include some header files. But I failed to find one.

Or do I have to learn autotool to achieve what I want?
An easy way?

 
Hmm, why you are trying to use tesseract withing Ellipse (personally I found to work with eclipse more difficult than other solutions, but it could be my problem) if you have no clue about standard compiler errors ;-)? 
That error means that linker is missing library that provide sem_init, sem_post, sem_wait, pthread_create on YOUR system (copying from other system does not always work).

--
Zdenko

zdenko podobny

unread,
Nov 20, 2012, 2:47:38 AM11/20/12
to tesser...@googlegroups.com
On Mon, Nov 19, 2012 at 9:36 PM, Linda Li <codingpo...@gmail.com> wrote:
Hah, I figured it out.
You are right, "undefined" does not mean "undeclared". So I think I found a one wrong lib.

I checked the Makefile, although a lot of strange words there, there are LIBS = -llept -lpthread
So I include pthread in it.
Now the tesseractmain.cpp builds. (only it, yes, I put other .cpp files containing main() to .txt files, wired, violent but worked : )

Thanks a lot for zdenop's help.

Hint: look at Makefile.am - it is simplier and Makefile(.in) is generated from it (autotools do it).  
--
You received this message because you are subscribed to the Google
Groups "tesseract-ocr" group.
To post to this group, send email to tesser...@googlegroups.com
To unsubscribe from this group, send email to
tesseract-oc...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en



--
Zdenko

zdenko podobny

unread,
Nov 20, 2012, 10:49:27 AM11/20/12
to tesser...@googlegroups.com
On Mon, Nov 19, 2012 at 5:57 PM, Linda Li <codingpo...@gmail.com> wrote:
Thanks.


On Monday, November 19, 2012 10:30:07 AM UTC-6, zdenop wrote:
On Sun, Nov 18, 2012 at 11:49 PM, Linda Li <codingpo...@gmail.com> wrote:

Now building succeeds.

Compile has errors, complaining there are several main() functions.

I have little knowledge of makefile, which I guess can circumvent this problem, so I renamed all functions with main(), except tesseractmain.cpp, to .txt files.


Are you sure you know what are you doing? 

I think it is an easy and feasible way, although sounds awkward.


 

Google, found http://code.google.com/p/tesseract-ocr/issues/detail?id=757

The build fails as sem_init is in librt on Solaris. The attached patch adds searching for sem_init in librt. After that the build succeeds.”


Search librt in the libraries:

/usr/lib/x86_64-linux-gnu/

librt.a

librt.so


So I include /usr/lib/x86_64-linux-gnu into the Library Paths

Include rt into Libraries.


Rebuild the project with hope....


Again, the same compiling errors are:

svutil.cpp:129: undefined reference to `sem_init'

svutil.cpp:137: undefined reference to `sem_post'

svutil.cpp:145: undefined reference to `sem_wait'

svutil.cpp:188: undefined reference to `pthread_create'

I guess I need to include some header files. But I failed to find one.

Or do I have to learn autotool to achieve what I want?
An easy way?

 
Hmm, why you are trying to use tesseract within Ellipse (personally I found to work with eclipse more difficult than other solutions, but it could be my problem) if you have no clue about standard compiler errors ;-)? 
That error means that linker is missing library that provide sem_init, sem_post, sem_wait, pthread_create on YOUR system (copying from other system does not always work).

--
Zdenko


Then what should I use?
I am in Ubuntu. The available and popular C++ IDE is Eclipse.
And since I want to go to the dubugging mode for tesseractmain.cpp (I want to look into the ocr code), it is better to use a IDE. It would be appreciated if you advice more easier options.

Personally I tried Eclipse too (as first option) and I finish with QT Creator[1]. It it lighter and much easier (to learn & use) for me. I do not need to read documentation, just to try some QT project examples...



I did not copy the missing library. The librt is in the computer. I just include the library path and file in the project properties.  But it still complains, so I think I need to find and include the corresponding header.
What is the header file for librt?
Thanks.



--
Zdenko

Hsrt

unread,
Feb 26, 2014, 10:23:05 AM2/26/14
to tesser...@googlegroups.com
Hello, I read these suggestions but I am not clear yet. I search some videos but I dont know how I start.

I want to run on eclipse(linux) a simple code like this http://code.google.com/p/tesseract-ocr/wiki/APIExample. What should I do first step?

16 Kasım 2012 Cuma 04:03:16 UTC+2 tarihinde Linda Li yazdı:
I want to build the tesseract 3.02.02 project so that I can modify some code to tune it to some specific task.

Version: tesseract 3.02.02
Ubuntu 12.04, Eclipse Juno

I put the tesseract into the Eclipse project.

Include directories
/usr/local/include
/usr/local
/usr/include/leptonica
and all file directories of the tesseract source, e.g. /Tesseract302Test/src/api, etc.

Library Paths:
/usr/local/lib

Libraries
/lept

Then I build the project.

The error pops out:
../src/training/classifier_tester.cpp:20:35: fatal error: base/commandlineflags.h: No such file or directory
compilation terminated.


There is no such commandlineflags.h file.
How can I solve this problem?
Reply all
Reply to author
Forward
0 new messages