Compilation error
Trying to perform the command:
go get -u github.com/d2r2/go-bsbmp
I get the response:
# github.com/d2r2/go-i2c
../../../go/src/github.com/d2r2/go-i2c/i2c.go:36:26: undefined: I2C_SLAVE
What am I doing wrong?
Hi @dveoz. What OS you use, is this a Linux? Do you perform this command on embedded device? Which one? Could you give an output for: 1) uname -a; 2) go env?
Hi @d2r2, thanks for reply!
I tried this command on different machines: Raspberry PI Zero as we as Mac. here is the output: RPi:
Linux rpi 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l GNU/Linux
---
GO111MODULE=""
GOARCH="arm"
GOBIN=""
GOCACHE="/home/pi/.cache/go-build"
GOENV="/home/pi/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm"
GCCGO="gccgo"
GOARM="6"
AR="ar"
CC="gcc"
CXX="g++"
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 -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build487701749=/tmp/go-build -gno-record-gcc-switches"
For Mac:
Darwin iMac.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
---
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="$HOME/Library/Caches/go-build"
GOENV="$HOME/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="$HOME/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="$HOME/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"
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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/08/9hmcbk9962lf3wh287y2jhqw0000gn/T/go-build338919572=/tmp/go-build -gno-record-gcc-switches -fno-common"
Thanks for debug output.
I can find explanation, why it doesn't work on Mac, but it's not clear for me what is wrong on Raspberry PI Zero. File https://github.com/d2r2/go-i2c/blob/master/cgo.go limit I2C_SLAVE constant definition to the Linux platform...
I can update build constraint in the header from version:
// +build linux,cgo
to the version:
// +build linux,cgo darwin,cgo
and perhaps it resolve the issue with Mac.
But before we will move forward, let make another test. Try to run this line on both devices and reply about results:
CGO_ENABLED="0" go get -u -v github.com/d2r2/go-bsbmp