faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.03k stars 150 forks source link

undefined: newDriver compile linux from mac #125

Open ramacatur opened 3 years ago

ramacatur commented 3 years ago

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

cebarks commented 3 years ago

Does it compile normally when just building for macos?

ramacatur commented 3 years ago

Does it compile normally when just building for macos?

Yes, it is normally when building for macos.

cebarks commented 3 years ago

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.

ramacatur commented 3 years ago

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

cebarks commented 3 years ago

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

wxxhub commented 1 year ago

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

wxxhub commented 1 year ago

图片