beep
beep copied to clipboard
undefined: newDriver compile linux from mac
Hey, I try compile my application to linux from mac but I got error like this:
env GOOS=linux GOARCH=amd64 go build -v
github.com/hajimehoshi/oto
# github.com/hajimehoshi/oto
../github.com/hajimehoshi/oto/context.go:69:12: undefined: newDriver
this is my go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ramacatur/Library/Caches/go-build"
GOENV="/Users/ramacatur/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Volumes/Data/code/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Volumes/Data/code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4n/dt47c6rn3654505gxvvrmjc80000gn/T/go-build3898342957=/tmp/go-build -gno-record-gcc-switches -fno-common"
thanks for the solution
Does it compile normally when just building for macos?
Does it compile normally when just building for macos?
Yes, it is normally when building for macos.
Do you have your go.mod setup correctly? maybe try a go mod tidy
to make sure all your imports are in your go.mod.
I don't use go.mod in my code. do i have to use linux to compile?
Ah that's the problem then. you must be missing the dependency somehow. I'd recommend looking into using go modules to manage your dependencies. You might be able to fix your build with go get -u https://github.com/faiface/beep@latest
but I'm not 100%.
I had the same problem,setting Environment CGO_ENABLED=1 in the IDE solves the problem.