beep icon indicating copy to clipboard operation
beep copied to clipboard

undefined: newDriver compile linux from mac

Open ramacatur opened this issue 3 years ago • 7 comments

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

ramacatur avatar Jun 23 '21 14:06 ramacatur

Does it compile normally when just building for macos?

cebarks avatar Jun 23 '21 18:06 cebarks

Does it compile normally when just building for macos?

Yes, it is normally when building for macos.

ramacatur avatar Jun 24 '21 02:06 ramacatur

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.

cebarks avatar Jun 24 '21 03:06 cebarks

I don't use go.mod in my code. do i have to use linux to compile?

ramacatur avatar Jun 24 '21 05:06 ramacatur

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%.

cebarks avatar Jun 24 '21 06:06 cebarks

图片 I had the same problem,setting Environment CGO_ENABLED=1 in the IDE solves the problem.

wxxhub avatar May 31 '23 14:05 wxxhub

图片

wxxhub avatar May 31 '23 14:05 wxxhub