Tess4J on MacOsX

5,977 views
Skip to first unread message

Masiar Babazadeh

unread,
Jul 10, 2013, 5:52:29 AM7/10/13
to tesser...@googlegroups.com
Hello, I installed Tesseract and all the stuff on my Mac. By running via terminal the command apparently it works.
I'm trying to run it from Eclipse (following one of the examples on the website), but I receive the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'TessBaseAPICreate': dlsym(0x7fb714d3db20, TessBaseAPICreate): symbol not found

at com.sun.jna.Function.<init>(Function.java:179)

at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:391)

at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:371)

at com.sun.jna.Library$Handler.invoke(Library.java:205)

at com.sun.proxy.$Proxy12.TessBaseAPICreate(Unknown Source)

at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)

at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)

at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)

at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)

at AccountCreator.decrypt(AccountCreator.java:177)

at AccountCreator.submittingForm(AccountCreator.java:100)

at AccountCreator.<init>(AccountCreator.java:197)

at Main.main(Main.java:5)


What can I do to solve this issue? Anybody has an idea?

Thanks a lot!

fontecha

unread,
Nov 15, 2013, 7:29:14 AM11/15/13
to tesser...@googlegroups.com
I have the same problem.
Do you find any solution or workarround?

Thanks.

Quan Nguyen

unread,
Nov 15, 2013, 6:58:03 PM11/15/13
to tesser...@googlegroups.com
Do you get or have libtesseract.dylib in your system path?

fontecha

unread,
Nov 18, 2013, 5:09:31 AM11/18/13
to tesser...@googlegroups.com
Hi Quan.

I installed tesseract with brew:
  brew install tesseract --all-languages


The library is in the system path /usr/local/lib/ and I added it to the classpath in the eclipse project


Command line mode works fine, but when I try to work with tess4j the exception I found is :
java.lang.UnsatisfiedLinkError: Error looking up function 'TessBaseAPICreate': dlsym(0x7f942aa0b910, TessBaseAPICreate): symbol not found
 
I'm debugging tess4j code and when I launch net.sourceforge.tess4j.TessAPI1Test.testTessBaseAPIRect the exception is launched when invokes
 this.peer = library.getSymbolAddress(functionName); -->[com.sun.jna.NativeLibrary.getSymbolAddress("TessBaseAPICreate")]


Full trace :
java.lang.UnsatisfiedLinkError: Error looking up function 'TessBaseAPICreate': dlsym(0x7fb932a1e4e0, TessBaseAPICreate): symbol not found
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Native.register(Native.java:1509)
at com.sun.jna.Native.register(Native.java:1396)
at com.sun.jna.Native.register(Native.java:1156)
at net.sourceforge.tess4j.TessAPI1.<clinit>(TessAPI1.java:37)
at net.sourceforge.tess4j.TessAPI1Test.setUp(TessAPI1Test.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)





Also I've wrote this test code :
  TessAPI api =  (TessAPI) Native.loadLibrary("tesseract, TessAPI.class);
    api.TessVersion();

The first line doesn't throw exception ( it makes me think library is found and loaded), but the second line throws similar exception:

java.lang.UnsatisfiedLinkError: Error looking up function 'TessVersion': dlsym(0x7fb0b1a16fc0, TessVersion): symbol not found
at com.sun.jna.Function.<init>(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Library$Handler.invoke(Library.java:199)

...



Thank you for any help you can provide 

Quan Nguyen

unread,
Nov 18, 2013, 8:15:21 AM11/18/13
to tesser...@googlegroups.com
The dylib, a native shared library, should be in the system path, not classpath, as classpath is for Java class and JAR files.

What is the exact name of your dylib by the way?

Quan Nguyen

unread,
Nov 18, 2013, 6:36:29 PM11/18/13
to fontecha, tesser...@googlegroups.com
Glad that it worked out for you. Thanks.


On Mon, Nov 18, 2013 at 7:29 AM, fontecha <font...@gmail.com> wrote:
It's in the system path.

I just find the solution.

I don't know why when I installed the tesseract with the command:
      brew install tesseract --all-languages

it was installed the 3.01 version.

I've executed this commands:
    brew uninstall testesseract
    brew cleanup
    brew install tesseract       (in this case without the param --all-languages)

and now the current installed version is 3.02

Now tests are ok and green :)


Thanks.
Reply all
Reply to author
Forward
0 new messages