gosseract: 'tesseract/baseapi.h' file not found

% go test ./...
# github.com/otiai10/gosseract/tesseract
tesseract/tess.cpp:1:10: fatal error: 'tesseract/baseapi.h' file not found
FAIL    github.com/otiai10/gosseract [build failed]

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 25 (9 by maintainers)

Most upvoted comments

Need to install libleptonica-dev and libtesseract-dev.

For anybody else experiencing this issue on an M1 mac:

CPATH=/opt/homebrew/include  LIBRARY_PATH=/opt/homebrew/lib go get -t github.com/otiai10/gosseract

Actually, I think I have a solution. This problem can occur when the command-line developer tools for Xcode are not installed, or when you upgrade Xcode.

To fix, do the following:

brew remove tesseract
brew remove leptonica
xcode-select --install
brew install tesseract
go get github.com/otiai10/gosseract

This worked for me.

I try to install gosseract on FreeBSD 11.0. I have tesseract and leptonica installed. My baseapi.h is at /usr/local/include/tesseract/baseapi.h but I still get:

go get github.com/otiai10/gosseract
# github.com/otiai10/gosseract/tesseract
tess.cpp:1:10: fatal error: 'tesseract/baseapi.h' file not found

Is there any way to tell where to find the file manually?

EDIT: I hacked my way through the C imports changing: tesseract/wrapper.go

 3 /*
 4 #cgo LDFLAGS: -L/usr/local/lib -llept -ltesseract
 5 #include "tess.h"
 6 */

and tesseract/tess.cpp

  1 #include "/usr/local/include/tesseract/baseapi.h"
  2 #include "/usr/local/include/leptonica/allheaders.h"

This way I got it working

on osx, this is solved using homebrew: brew install tesseract

For anybody else experiencing this issue on an M1 mac:

CPATH=/opt/homebrew/include  LIBRARY_PATH=/opt/homebrew/lib go get -t github.com/otiai10/gosseract

This works charm 🚀

+1

brew remove tesseract brew remove leptonica xcode-select --install brew install tesseract go get github.com/otiai10/gosseract

worked like a charm.

I follow this command brew remove tesseract brew remove leptonica xcode-select --install brew install tesseract go get github.com/otiai10/gosseract

same error

same here I have xcode-select installed already

windows get the same error? I put here. please help.

# github.com/otiai10/gosseract/tesseract
F:\mygo\src\github.com\otiai10\gosseract\tesseract\tess.cpp:1:31: fatal error: tesseract/baseapi.h: No such file or directory
compilation terminated.

I experienced same issue here. This error keep showing up even tesseract already installed. Am I missing something? I use yosemite

$ brew install tesseract
Warning: tesseract-3.04.00 already installed

$ brew install leptonica
Warning: leptonica-1.72 already installed

$ go test ./
# github.com/otiai10/gosseract/tesseract
tesseract/tess.cpp:1:10: fatal error: 'tesseract/baseapi.h' file not found
FAIL    github.com/otiai10/gosseract [build failed]