go-sqlite3
go-sqlite3 copied to clipboard
Issue with Windows Subsystem for Linux (WSL)
Hi, during my app development I have faced with issue. Error:
tyaonami@local:~/forum$ go run .
# forum
/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/pkg/tool/linux_amd64/link: running gcc-5 failed: exit status 1
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000010.o: in function `pthreadMutexTry':
/home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:27514: undefined reference to `pthread_mutex_trylock'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000010.o: in function `sqlite3ThreadCreate':
/home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:31287: undefined reference to `pthread_create'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000010.o: in function `pthreadMutexAlloc':
/home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:27369: undefined reference to `pthread_mutexattr_init'
/home/linuxbrew/.linuxbrew/bin/ld: /home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:27370: undefined reference to `pthread_mutexattr_settype'
/home/linuxbrew/.linuxbrew/bin/ld: /home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:27372: undefined reference to `pthread_mutexattr_destroy'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000010.o: in function `sqlite3ThreadJoin':
/home/tyaonami/go/pkg/mod/github.com/mattn/[email protected]/sqlite3-binding.c:31307: undefined reference to `pthread_join'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000016.o: in function `_cgo_try_pthread_create':
/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_libinit.c:100: undefined reference to `pthread_create'
/home/linuxbrew/.linuxbrew/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_libinit.c:102: undefined reference to `pthread_detach'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000017.o: in function `x_cgo_init':
/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_linux_amd64.c:46: undefined reference to `pthread_attr_getstacksize'
/home/linuxbrew/.linuxbrew/bin/ld: /tmp/go-link-456674004/000017.o: in function `_cgo_sys_thread_start':
/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_linux_amd64.c:67: undefined reference to `pthread_sigmask'
/home/linuxbrew/.linuxbrew/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_linux_amd64.c:70: undefined reference to `pthread_attr_getstacksize'
/home/linuxbrew/.linuxbrew/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/src/runtime/cgo/gcc_linux_amd64.c:75: undefined reference to `pthread_sigmask'
collect2: error: ld returned 1 exit status
My code:
package main
import (
"fmt"
_ "github.com/mattn/go-sqlite3"
)
func main() {
fmt.Println("Hello")
}
Go environment:
tyaonami@local:~/forum$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tyaonami/.cache/go-build"
GOENV="/home/tyaonami/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/tyaonami/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/tyaonami/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/linuxbrew/.linuxbrew/Cellar/go/1.16.5/libexec/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc-5"
CXX="g++-5"
CGO_ENABLED="1"
GOMOD="/home/tyaonami/forum/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3584474454=/tmp/go-build -gno-record-gcc-switches"
gcc version
tyaonami@local:~/forum$ gcc-5 --version
gcc-5 (Homebrew GCC 5.5.0_7) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
tyaonami@local:~/forum$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Can you test with go run -ldflags="-extldflags='-lpthread'" .?