Go build fails on windows 10 (undefined reference)
Fentonz opened this issue · 2 comments
Summary
I cant get gosseract to work on Windows10. I managed to build tesseract and leptonica with VS 2019, but I had issues with pathing in many header files. I solved that by adding absolute path to those header files like this:
But now it seems like I have an "undefined reference" issue when calling "go build". I have no idea what to do...
Reproducibility
Build tesseract and leptonica with VS 2019 on windows 10. Add absolute paths to headers. Go build an example file with gosseract package.
Reproducibility Frequency
- 100% i guess, cant get it working :)
Environment
Gosseract version: main (2762ecf)
OS: Windows 10 64-bit
Tesseract and leptonica compiler: Visual Studio 2019 (CMake)
Go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Fenton\AppData\Local\go-build
set GOENV=C:\Users\Fenton\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\cygwin64\home\Fenton\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\cygwin64\tmp\go-build007336666=/tmp/go-build -gno-record-gcc-switches
Go version
go version go1.13.5 windows/amd64
Error message
$ go build
# github.com/otiai10/gosseract
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: $WORK\b002_x003.o: in function tesseract::TessBaseAPI::Init(char const*, char const*)': /home/Fenton/go/src/github.com/otiai10/gosseract/C:\cygwin64\home\Fenton\go\src\github.com\otiai10\gosseract\tesseract\include\baseapi.h:214: undefined reference to
tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, std::vector<std::string, std::allocatorstd::string > const*, std::vector<std::string, std::allocatorstd::string > const*, bool)'
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /home/Fenton/go/src/github.com/otiai10/gosseract/C:\cygwin64\home\Fenton\go\src\github.com\otiai10\gosseract\tesseract\include\baseapi.h:214: undefined reference to tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, std::vector<std::string, std::allocator<std::string> > const*, std::vector<std::string, std::allocator<std::string> > const*, bool)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: $WORK\b002\_x003.o:/home/Fenton/go/src/github.com/otiai10/gosseract/tessbridge.cpp:114: undefined reference to
tesseract::TessBaseAPI::Recognize(tesseract::ETEXT_DESC*)'
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: $WORK\b002_x003.o:/home/Fenton/go/src/github.com/otiai10/gosseract/tessbridge.cpp:178: undefined reference to tesseract::TessBaseAPI::Recognize(tesseract::ETEXT_DESC*)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: $WORK\b002\_x003.o: in function
tesseract::TessBaseAPI::Init(char const*, char const*)':
/home/Fenton/go/src/github.com/otiai10/gosseract/C:\cygwin64\home\Fenton\go\src\github.com\otiai10\gosseract\tesseract\include\baseapi.h:214: undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, std::vector<std::string, std::allocatorstd::string > const*, std::vector<std::string, std::allocatorstd::string > const*, bool)'
collect2: error: ld returned 1 exit status