ungerik / go-cairo

Go binding for the cairo graphics library
Other
142 stars 32 forks source link

build failing while cross compilation. #26

Open patabhu opened 1 year ago

patabhu commented 1 year ago

i am building my project using below cmd. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o handlerBuild cmd/handler/main.go Error generated: imports github.com/ungerik/go-cairo: build constraints exclude all Go files in /home/oem/go/pkg/mod/github.com/ungerik/go-cairo@v0.0.0-20220815093914-e24bd4259cef can someone explain me, what is happening over here ?

my system details on which i am try to build.

GO111MODULE="auto"
GOARCH="amd64"
GOBIN="/home/oem/go/bin"
GOCACHE="/home/oem/.cache/go-build"
GOENV="/home/oem/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oem/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oem/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/oem/go/src/file-core/go.mod"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2645311516=/tmp/go-build -gno-record-gcc-switches"
mbaraa commented 7 months ago

@patabhu you are compiling with CGO_ENABLED set to 0 which is incorrect, since go-cairo is a wrapper for the C version of cairo, you need to tell the Go compiler that you're using C in your compilation, so set CGO_ENABLED to 1 and you shall compile peacefully!