-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to compile for windows on macOS. Says first call to package not found #112
Comments
got the same error
package main
import (
//"flag"
"fmt"
"io/ioutil"
"github.com/otiai10/gosseract"
"github.com/whitman-colm/go-lib/src/input"
)
var (
image string
output string
)
/*func init() {
st1 := `Path to the image to be OCR'd.`
st2 := `Where to direct output of file. Leave blank to pipe to stdout.`
flag.StringVar(&image, "i", "", st1)
flag.StringVar(&output, "o", "", st2)
flag.Parse()
}*/
func main() {
image := ""
output := ""
if image == "" {
fmt.Println("Please provide the path to an image file.")
fmt.Println("Accepted formats are .png, .jpeg, and .tiff.")
fmt.Println("If you're not sure what a path is, drag an image file into this window.")
image = input.StringInput("> ")
}
if output == "" {
fmt.Println("Provide an output file (leave blank to print result to console)")
output = input.StringInput("> ")
}
client := gosseract.NewClient()
defer client.Close()
client.SetImage(image)
text, err := client.Text()
if err != nil {
panic(err)
}
if output != "" {
tAsByte := []byte(text)
err = ioutil.WriteFile(output, tAsByte, 0644)
if err != nil {
panic(err)
}
} else {
fmt.Println(text)
_ = input.StringInput("press enter when done. ")
}
} |
% brew search mingw
% brew install mingw-w64
% CPLUS_INCLUDE_PATH=/usr/local/include \
CGO_ENABLED=1 \
CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \
GOOS=windows \
GOARCH=amd64 \
go build -o ./out.exe main.go
# github.com/otiai10/gosseract
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `Create':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:12: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `Free':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:18: undefined reference to `tesseract::TessBaseAPI::End()'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `tesseract::TessBaseAPI::Init(char const*, char const*)':
/usr/local/include/tesseract/baseapi.h:241: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `Init':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:32: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `tesseract::TessBaseAPI::Init(char const*, char const*)':
/usr/local/include/tesseract/baseapi.h:241: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `SetImage':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:45: undefined reference to `pixRead'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `SetVariable':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:40: undefined reference to `tesseract::TessBaseAPI::SetVariable(char const*, char const*)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `SetImage':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:46: undefined reference to `tesseract::TessBaseAPI::SetImage(Pix*)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `SetPageSegMode':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:52: undefined reference to `tesseract::TessBaseAPI::SetPageSegMode(tesseract::PageSegMode)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `GetPageSegMode':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:57: undefined reference to `tesseract::TessBaseAPI::GetPageSegMode() const'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `UTF8Text':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:62: undefined reference to `tesseract::TessBaseAPI::GetUTF8Text()'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `HOCRText':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:67: undefined reference to `tesseract::TessBaseAPI::GetHOCRText(int)'
/var/folders/__/xxcbtw6j0tb681fjv1lbnlg40000gn/T/go-build517521774/github.com/otiai10/gosseract/_obj/tessbridge.cpp.o: In function `Version':
../../proj/go/src/github.com/otiai10/gosseract/tessbridge.cpp:72: undefined reference to `tesseract::TessBaseAPI::Version()'
collect2: error: ld returned 1 exit status
% |
go test -v github.com/otiai10/gosseract
go get github.com/whitman-colm/go-lib/src/input
apt-get -y install mingw-w64
apt-get install -y g++-multilib
CPLUS_INCLUDE_PATH=/usr/include \
CGO_ENABLED=1 \
CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \
GOOS=windows \
GOARCH=amd64 \
go build -o ./out.exe /tmp/main.go
|
Leptonica and Tesseract have to be built by the cross-compiler to be able to build on windows, otherwise, those libraries will not be linked correctly and the package will fail to build properly. |
ah... |
How to do on macos,please? |
he i got undefined: gosseract.NewClientcompilerUndeclaredImportedName client := gosseract.NewClient() my device is windows 11 can help ? |
have the same issue |
Undefined package used when attempting to compile for windows:
I have built a tiny wrapper for Gosseract for my own personal use, but when attempting to compile for windows (on mac) I get an error. There is never an issue and the system works perfectly when compiling for macOS but I get an error without fail when compiling for windows.
Reproducibility
Reproducility Frequency
How to reproduce:
Command I'm running:
Environment
Take the entire script if you must, sorry about the verbosity but the windows compilation is for my friends who aren't anything like computer savvy and need things spelled out for them (which is why I've commented out the init statement for the time being:
main.go.txt
)
The text was updated successfully, but these errors were encountered: