mattn / go-sqlite3

sqlite3 driver for go using database/sql
http://mattn.github.io/go-sqlite3
MIT License
7.91k stars 1.1k forks source link

win32 go build fail. #771

Open Peakchen opened 4 years ago

Peakchen commented 4 years ago

windows_386\link.exe: running gcc failed: exit status 1 go-link-162727447\000000.o: file not recognized: File format not recognized collect2.exe: error: ld returned 1 exit status

how to resolve this problem and cgo?

mattn commented 4 years ago

Are you doing cross-compilation?

Peakchen commented 4 years ago

Are you doing cross-compilation?

first,i do cross-compilation at win64,but it fail,then i try at win32,Suddenly this problem occurs. please help me resolve that, I have been pinning this issue for several days.

Peakchen commented 4 years ago

Are you doing cross-compilation?

first,i do cross-compilation at win64,but it fail,then i try at win32,Suddenly this problem occurs. please help me resolve that, I have been pinning this issue for several days.

env: mingw or tdm 5.1, go version go1.12.7 windows/386.

mattn commented 4 years ago

You need to use 32bit C compiler.

Peakchen commented 4 years ago

You need to use 32bit C compiler.

the third reply what has used 32bit compiler about mingw or tdm

mattn commented 4 years ago

Could you please paste result of go build -x ?

Peakchen commented 4 years ago

now,i only compile success by single go file,what is main. go. others is can not.

rittneje commented 4 years ago

@Peakchen Can you please post the exact go build command you are running, as well as the output of running go env and where gcc?

ysllyfe commented 2 years ago

the same problem go env

set GO111MODULE=
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files (x86)\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files (x86)\Go\pkg\tool\windows_386
set GOVCS=
set GOVERSION=go1.17.6
set GCCGO=gccgo
set GO386=sse2
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\go_ic\go.mod
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=-m32 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build3864796519=/tmp/go-build -gno-record-gcc-switches

where gcc

C:\TDM-GCC-32\bin\gcc.exe

gcc versions

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/tdm-gcc-32/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC Build-2'
Thread model: win32
gcc version 9.2.0 (MinGW.org GCC Build-2)
rittneje commented 2 years ago

@ysllyfe Can you share the specific go build command you are running, and the output you are seeing?

Does the issue persist with go build -a? Can you also try with go build -x and share the output from that?

ysllyfe commented 2 years ago

@rittneje

go build output

C:\Program Files (x86)\Go\pkg\tool\windows_386\link.exe: running gcc failed: exit status 1
C:\Users\ys\AppData\Local\Temp\go-link-2705782361\000000.o: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status

go build -a same as go build

PS C:\Users\ys\go_ic> go build -a
# go_ic
C:\Program Files (x86)\Go\pkg\tool\windows_386\link.exe: running gcc failed: exit status 1
C:\Users\ys\AppData\Local\Temp\go-link-3686115457\000000.o: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status

go build -x

PS C:\Users\ys\go_ic> go build -x
WORK=C:\Users\ys\AppData\Local\Temp\go-build3731535320
mkdir -p $WORK\b001\
cat >$WORK\b001\importcfg.link << 'EOF' # internal
packagefile go_ic=C:\Users\ys\AppData\Local\go-build\9f\9f1285d01c43fc694f6462eb336f038a9eb4e3e60f8347bb3a8c95892452113f-d
packagefile bytes=C:\Program Files (x86)\Go\pkg\windows_386\bytes.a
packagefile database/sql=C:\Program Files (x86)\Go\pkg\windows_386\database\sql.a
packagefile encoding/binary=C:\Program Files (x86)\Go\pkg\windows_386\encoding\binary.a
packagefile encoding/hex=C:\Program Files (x86)\Go\pkg\windows_386\encoding\hex.a
packagefile errors=C:\Program Files (x86)\Go\pkg\windows_386\errors.a
packagefile flag=C:\Program Files (x86)\Go\pkg\windows_386\flag.a
packagefile fmt=C:\Program Files (x86)\Go\pkg\windows_386\fmt.a
packagefile github.com/go-ini/ini=C:\Users\ys\AppData\Local\go-build\f8\f89e0e556fef722cd7c61f2e4a73ebe7705401f9855b04315dc78d792d247066-d
packagefile github.com/gorilla/websocket=C:\Users\ys\AppData\Local\go-build\a2\a29ed76492d2ab5632711e5dac1386ccfce686ca2e457fa472f6612ef8699b66-d
packagefile github.com/lxn/walk=C:\Users\ys\AppData\Local\go-build\32\32b9cc96db68db53e35a02fb840a65555ae034b29029831dc5aa13fff18f2537-d
packagefile github.com/lxn/walk/declarative=C:\Users\ys\AppData\Local\go-build\38\3846aba0d7ec02abe7b3191ced074c59f43575ea6982cb6c5edd9b0702c5c354-d
packagefile github.com/mattn/go-sqlite3=C:\Users\ys\AppData\Local\go-build\af\af9f5f3c8fbb0fbdf511b1c2e72191d8cd17a1d5c9ff494a47f61fa7840689d1-d
packagefile log=C:\Program Files (x86)\Go\pkg\windows_386\log.a
packagefile net=C:\Program Files (x86)\Go\pkg\windows_386\net.a
packagefile net/http=C:\Program Files (x86)\Go\pkg\windows_386\net\http.a
packagefile reflect=C:\Program Files (x86)\Go\pkg\windows_386\reflect.a
packagefile strconv=C:\Program Files (x86)\Go\pkg\windows_386\strconv.a
packagefile strings=C:\Program Files (x86)\Go\pkg\windows_386\strings.a
packagefile syscall=C:\Program Files (x86)\Go\pkg\windows_386\syscall.a
packagefile time=C:\Program Files (x86)\Go\pkg\windows_386\time.a
packagefile runtime=C:\Program Files (x86)\Go\pkg\windows_386\runtime.a
packagefile internal/bytealg=C:\Program Files (x86)\Go\pkg\windows_386\internal\bytealg.a
packagefile io=C:\Program Files (x86)\Go\pkg\windows_386\io.a
packagefile unicode=C:\Program Files (x86)\Go\pkg\windows_386\unicode.a
packagefile unicode/utf8=C:\Program Files (x86)\Go\pkg\windows_386\unicode\utf8.a
packagefile context=C:\Program Files (x86)\Go\pkg\windows_386\context.a
packagefile database/sql/driver=C:\Program Files (x86)\Go\pkg\windows_386\database\sql\driver.a
packagefile sort=C:\Program Files (x86)\Go\pkg\windows_386\sort.a
packagefile sync=C:\Program Files (x86)\Go\pkg\windows_386\sync.a
packagefile sync/atomic=C:\Program Files (x86)\Go\pkg\windows_386\sync\atomic.a
packagefile math=C:\Program Files (x86)\Go\pkg\windows_386\math.a
packagefile internal/reflectlite=C:\Program Files (x86)\Go\pkg\windows_386\internal\reflectlite.a
packagefile os=C:\Program Files (x86)\Go\pkg\windows_386\os.a
packagefile internal/fmtsort=C:\Program Files (x86)\Go\pkg\windows_386\internal\fmtsort.a
packagefile bufio=C:\Program Files (x86)\Go\pkg\windows_386\bufio.a
packagefile io/ioutil=C:\Program Files (x86)\Go\pkg\windows_386\io\ioutil.a
packagefile regexp=C:\Program Files (x86)\Go\pkg\windows_386\regexp.a
packagefile compress/flate=C:\Program Files (x86)\Go\pkg\windows_386\compress\flate.a
packagefile crypto/rand=C:\Program Files (x86)\Go\pkg\windows_386\crypto\rand.a
packagefile crypto/sha1=C:\Program Files (x86)\Go\pkg\windows_386\crypto\sha1.a
packagefile crypto/tls=C:\Program Files (x86)\Go\pkg\windows_386\crypto\tls.a
packagefile encoding/base64=C:\Program Files (x86)\Go\pkg\windows_386\encoding\base64.a
packagefile encoding/json=C:\Program Files (x86)\Go\pkg\windows_386\encoding\json.a
packagefile math/rand=C:\Program Files (x86)\Go\pkg\windows_386\math\rand.a
packagefile net/http/httptrace=C:\Program Files (x86)\Go\pkg\windows_386\net\http\httptrace.a
packagefile net/url=C:\Program Files (x86)\Go\pkg\windows_386\net\url.a
packagefile github.com/lxn/win=C:\Users\ys\AppData\Local\go-build\43\438fc883001a8b18442086ba41877e49c9294a8b0bb508958eefe52e1ff23c7c-d
packagefile golang.org/x/sys/windows=C:\Users\ys\AppData\Local\go-build\5d\5dd5fd3758e20be00570b11a2b40271b5d5c7dcfa20a640261d18f32034d8a32-d
packagefile gopkg.in/Knetic/govaluate.v3=C:\Users\ys\AppData\Local\go-build\8d\8d26cbfc1b2b1c66ce1e09a35312ee9c6b7bbbac48ea33ea3df97fe3cc63abf0-d
packagefile image=C:\Program Files (x86)\Go\pkg\windows_386\image.a
packagefile image/color=C:\Program Files (x86)\Go\pkg\windows_386\image\color.a
packagefile math/big=C:\Program Files (x86)\Go\pkg\windows_386\math\big.a
packagefile path/filepath=C:\Program Files (x86)\Go\pkg\windows_386\path\filepath.a
packagefile runtime/debug=C:\Program Files (x86)\Go\pkg\windows_386\runtime\debug.a
packagefile text/tabwriter=C:\Program Files (x86)\Go\pkg\windows_386\text\tabwriter.a
packagefile crypto/sha256=C:\Program Files (x86)\Go\pkg\windows_386\crypto\sha256.a
packagefile crypto/sha512=C:\Program Files (x86)\Go\pkg\windows_386\crypto\sha512.a
packagefile runtime/cgo=C:\Program Files (x86)\Go\pkg\windows_386\runtime\cgo.a
packagefile vendor/golang.org/x/net/dns/dnsmessage=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\net\dns\dnsmessage.a
packagefile internal/itoa=C:\Program Files (x86)\Go\pkg\windows_386\internal\itoa.a
packagefile internal/nettrace=C:\Program Files (x86)\Go\pkg\windows_386\internal\nettrace.a
packagefile internal/poll=C:\Program Files (x86)\Go\pkg\windows_386\internal\poll.a
packagefile internal/singleflight=C:\Program Files (x86)\Go\pkg\windows_386\internal\singleflight.a
packagefile internal/syscall/windows=C:\Program Files (x86)\Go\pkg\windows_386\internal\syscall\windows.a
packagefile compress/gzip=C:\Program Files (x86)\Go\pkg\windows_386\compress\gzip.a
packagefile container/list=C:\Program Files (x86)\Go\pkg\windows_386\container\list.a
packagefile vendor/golang.org/x/net/http/httpguts=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\net\http\httpguts.a
packagefile vendor/golang.org/x/net/http/httpproxy=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\net\http\httpproxy.a
packagefile vendor/golang.org/x/net/http2/hpack=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\net\http2\hpack.a
packagefile vendor/golang.org/x/net/idna=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\net\idna.a
packagefile io/fs=C:\Program Files (x86)\Go\pkg\windows_386\io\fs.a
packagefile mime=C:\Program Files (x86)\Go\pkg\windows_386\mime.a
packagefile mime/multipart=C:\Program Files (x86)\Go\pkg\windows_386\mime\multipart.a
packagefile net/http/internal=C:\Program Files (x86)\Go\pkg\windows_386\net\http\internal.a
packagefile net/http/internal/ascii=C:\Program Files (x86)\Go\pkg\windows_386\net\http\internal\ascii.a
packagefile net/textproto=C:\Program Files (x86)\Go\pkg\windows_386\net\textproto.a
packagefile path=C:\Program Files (x86)\Go\pkg\windows_386\path.a
packagefile internal/abi=C:\Program Files (x86)\Go\pkg\windows_386\internal\abi.a
packagefile internal/goexperiment=C:\Program Files (x86)\Go\pkg\windows_386\internal\goexperiment.a
packagefile internal/unsafeheader=C:\Program Files (x86)\Go\pkg\windows_386\internal\unsafeheader.a
packagefile math/bits=C:\Program Files (x86)\Go\pkg\windows_386\math\bits.a
packagefile internal/oserror=C:\Program Files (x86)\Go\pkg\windows_386\internal\oserror.a
packagefile internal/race=C:\Program Files (x86)\Go\pkg\windows_386\internal\race.a
packagefile internal/syscall/windows/sysdll=C:\Program Files (x86)\Go\pkg\windows_386\internal\syscall\windows\sysdll.a
packagefile unicode/utf16=C:\Program Files (x86)\Go\pkg\windows_386\unicode\utf16.a
packagefile internal/syscall/windows/registry=C:\Program Files (x86)\Go\pkg\windows_386\internal\syscall\windows\registry.a
packagefile internal/cpu=C:\Program Files (x86)\Go\pkg\windows_386\internal\cpu.a
packagefile runtime/internal/atomic=C:\Program Files (x86)\Go\pkg\windows_386\runtime\internal\atomic.a
packagefile runtime/internal/math=C:\Program Files (x86)\Go\pkg\windows_386\runtime\internal\math.a
packagefile runtime/internal/sys=C:\Program Files (x86)\Go\pkg\windows_386\runtime\internal\sys.a
packagefile internal/syscall/execenv=C:\Program Files (x86)\Go\pkg\windows_386\internal\syscall\execenv.a
packagefile internal/testlog=C:\Program Files (x86)\Go\pkg\windows_386\internal\testlog.a
packagefile regexp/syntax=C:\Program Files (x86)\Go\pkg\windows_386\regexp\syntax.a
packagefile crypto=C:\Program Files (x86)\Go\pkg\windows_386\crypto.a
packagefile hash=C:\Program Files (x86)\Go\pkg\windows_386\hash.a
packagefile crypto/aes=C:\Program Files (x86)\Go\pkg\windows_386\crypto\aes.a
packagefile crypto/cipher=C:\Program Files (x86)\Go\pkg\windows_386\crypto\cipher.a
packagefile crypto/des=C:\Program Files (x86)\Go\pkg\windows_386\crypto\des.a
packagefile crypto/ecdsa=C:\Program Files (x86)\Go\pkg\windows_386\crypto\ecdsa.a
packagefile crypto/ed25519=C:\Program Files (x86)\Go\pkg\windows_386\crypto\ed25519.a
packagefile crypto/elliptic=C:\Program Files (x86)\Go\pkg\windows_386\crypto\elliptic.a
packagefile crypto/hmac=C:\Program Files (x86)\Go\pkg\windows_386\crypto\hmac.a
packagefile crypto/md5=C:\Program Files (x86)\Go\pkg\windows_386\crypto\md5.a
packagefile crypto/rc4=C:\Program Files (x86)\Go\pkg\windows_386\crypto\rc4.a
packagefile crypto/rsa=C:\Program Files (x86)\Go\pkg\windows_386\crypto\rsa.a
packagefile crypto/subtle=C:\Program Files (x86)\Go\pkg\windows_386\crypto\subtle.a
packagefile crypto/x509=C:\Program Files (x86)\Go\pkg\windows_386\crypto\x509.a
packagefile encoding/pem=C:\Program Files (x86)\Go\pkg\windows_386\encoding\pem.a
packagefile vendor/golang.org/x/crypto/chacha20poly1305=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\chacha20poly1305.a
packagefile vendor/golang.org/x/crypto/cryptobyte=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\cryptobyte.a
packagefile vendor/golang.org/x/crypto/curve25519=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\curve25519.a
packagefile vendor/golang.org/x/crypto/hkdf=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\hkdf.a
packagefile encoding=C:\Program Files (x86)\Go\pkg\windows_386\encoding.a
packagefile golang.org/x/sys/internal/unsafeheader=C:\Users\ys\AppData\Local\go-build\9d\9d32a82b86e377527cee52029ae872529c97d26dd3e3942fa12f52bdc57b73da-d
packagefile hash/crc32=C:\Program Files (x86)\Go\pkg\windows_386\hash\crc32.a
packagefile vendor/golang.org/x/text/secure/bidirule=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\text\secure\bidirule.a
packagefile vendor/golang.org/x/text/unicode/bidi=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\text\unicode\bidi.a
packagefile vendor/golang.org/x/text/unicode/norm=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\text\unicode\norm.a
packagefile mime/quotedprintable=C:\Program Files (x86)\Go\pkg\windows_386\mime\quotedprintable.a
packagefile crypto/internal/subtle=C:\Program Files (x86)\Go\pkg\windows_386\crypto\internal\subtle.a
packagefile crypto/internal/randutil=C:\Program Files (x86)\Go\pkg\windows_386\crypto\internal\randutil.a
packagefile vendor/golang.org/x/crypto/cryptobyte/asn1=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\cryptobyte\asn1.a
packagefile crypto/ed25519/internal/edwards25519=C:\Program Files (x86)\Go\pkg\windows_386\crypto\ed25519\internal\edwards25519.a
packagefile crypto/elliptic/internal/fiat=C:\Program Files (x86)\Go\pkg\windows_386\crypto\elliptic\internal\fiat.a
packagefile crypto/dsa=C:\Program Files (x86)\Go\pkg\windows_386\crypto\dsa.a
packagefile crypto/x509/pkix=C:\Program Files (x86)\Go\pkg\windows_386\crypto\x509\pkix.a
packagefile encoding/asn1=C:\Program Files (x86)\Go\pkg\windows_386\encoding\asn1.a
packagefile vendor/golang.org/x/crypto/chacha20=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\chacha20.a
packagefile vendor/golang.org/x/crypto/internal/subtle=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\internal\subtle.a
packagefile vendor/golang.org/x/crypto/poly1305=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\crypto\poly1305.a
packagefile vendor/golang.org/x/text/transform=C:\Program Files (x86)\Go\pkg\windows_386\vendor\golang.org\x\text\transform.a
packagefile crypto/ed25519/internal/edwards25519/field=C:\Program Files (x86)\Go\pkg\windows_386\crypto\ed25519\internal\edwards25519\field.a
EOF
mkdir -p $WORK\b001\exe\
cd .
"C:\\Program Files (x86)\\Go\\pkg\\tool\\windows_386\\link.exe" -o "$WORK\\b001\\exe\\a.out.exe" -importcfg "$WORK\\b001\\importcfg.link" -buildmode=pie -buildid=fynVib2T1CSf10SGLEOv/-CX-IE9qYqzlnXXxwu1e/VYaOzQMba73uLDCRCaHh/fynVib2T1CSf10SGLEOv -extld=gcc "C:\\Users\\ys\\AppData\\Local\\go-build\\9f\\9f1285d01c43fc694f6462eb336f038a9eb4e3e60f8347bb3a8c95892452113f-d"
# go_ic
C:\Program Files (x86)\Go\pkg\tool\windows_386\link.exe: running gcc failed: exit status 1
C:\Users\ys\AppData\Local\Temp\go-link-211100704\000000.o: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status