mattn / go-oci8

Oracle driver for Go using database/sql
https://mattn.kaoriya.net/
MIT License
630 stars 212 forks source link

get error when build linux target on windows10 #324

Closed 8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF closed 5 years ago

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

After reserch three days, I still get error as below.Please help me, ths.

go env

set GOARCH=amd64 set GOBIN= set GOCACHE=C:\go-build set GOEXE= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=linux set GOPATH=C:\Users\du.shaofeng\go set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=0 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=-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=C:\Users\DUSHAO~1.SFI\AppData\Local\Temp\go-build415498634=/tmp/go-build -gno-record-gcc-switches

gcc -v

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-7.3.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld Thread model: posix gcc version 7.3.0 (Rev2, Built by MSYS2 project)

where gcc

c:\msys64\mingw64\bin\gcc.exe

pkg-config --cflags oci8

-Ic:/msys64/mingw64/sdk/include/

go get github.com/mattn/go-oci8

github.com/mattn/go-oci8 C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:14:10: undefined: OCI8Connector C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:20:22: undefined: OCI8Connector C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:21:9: undefined: OCI8Driver C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:25:22: undefined: OCI8Connector C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:10:41: undefined: namedValue C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:16:13: undefined: OCI8Conn C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:25:13: undefined: OCI8Conn C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:34:13: undefined: OCI8Stmt C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:43:13: undefined: OCI8Stmt C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:52:13: undefined: OCI8Conn C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:21:9: too many errors

oci8.pc

Package Information for pkg-config prefix=C:/oracle122 libdir=${prefix} includedir=${prefix}/sdk/include/ gcclib=C:/msys64/mingw64/lib

Name: OCI Description: Oracle database engine dushaofeng Version: 12.2 Libs: -L${libdir} -L${gcclib} -lclntsh Libs.private: Cflags: -I${includedir}

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

@mattn please help me.

MichaelS11 commented 5 years ago

https://github.com/mattn/go-oci8/issues/262

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

Thank you ,I will try this way today. @MichaelS11

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

After install TMD on windows10 ,I can see the new gcc compile, but alse get error with get order. Can you help me? Ths. @MichaelS11

C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:14:10: undefined: OCI8Connector
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:20:22: undefined: OCI8Connector
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:21:9: undefined: OCI8Driver
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:25:22: undefined: OCI8Connector
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:10:41: undefined: namedValue
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:16:13: undefined: OCI8Conn
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:25:13: undefined: OCI8Conn
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:34:13: undefined: OCI8Stmt
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:43:13: undefined: OCI8Stmt
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\oci8_go18.go:52:13: undefined: OCI8Conn
C:\Users\du.shaofeng\go\src\github.com\mattn\go-oci8\connector.go:21:9: too many errors

go env

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\du.shaofeng.SFIT\AppData\Local\go-build
set GOEXE=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=linux
set GOPATH=C:\Users\du.shaofeng\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
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=-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=C:\Users\DUSHAO~1.SFI\AppData\Local\Temp\go-build272135038=/tmp/go-build -gno-record-gcc-switches

where gcc

c:\msys64\mingw64\bin\gcc.exe
C:\TDM-GCC-64\bin\gcc.exe
mattn commented 5 years ago

mingw64 gcc compiler does not support Linux elf target. I'm not familier to the cross C compiler on Windows, but one of them seems to be https://www.linaro.org/downloads/ .

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

mingw64 gcc compiler does not support Linux elf target. I'm not familier to the cross C compiler on Windows, but one of them seems to be https://www.linaro.org/downloads/ .

I will try again , Thanks for your time.

mattn commented 5 years ago

IMO, using docker or VirtualBox is easier than install cross C compiler.

MichaelS11 commented 5 years ago

I have only done cross compile from Linux to Windows. Lots of tools needed for cross compile to work. They are pretty easy to find and install on Linux. But Windows from Linux sounds tricky to me. Going to be a lot harder to find the needed tools.

I would either find a Linux system to build on or like @mattn said, setup some kind of VM on your Windows machine.

8lWVPjpTraP96fRCHvYFhrjVJmzrdFVF commented 5 years ago

Thanks for mattn and MichaelS11. I will try to use linux do this hard job. Thanks for all your help. and i will close this issue.