Cgo error on macOS

I hit an error of compiling very simple cgo example on macOS.

Here is the source code:

and here is the go env :

$ go env
GO111MODULE=“on”
GOARCH=“amd64”
GOBIN=“”
GOCACHE=“/Users/zhangwei/Library/Caches/go-build”
GOENV=“/Users/zhangwei/Library/Application Support/go/env”
GOEXE=“”
GOEXPERIMENT=“”
GOFLAGS=“”
GOHOSTARCH=“amd64”
GOHOSTOS=“darwin”
GOMODCACHE=“/Users/zhangwei/go/pkg/mod”
GOOS=“darwin”
GOPROXY=“https://goproxy.cn,direct”
GOROOT=“/usr/local/opt/go/libexec”
GOSUMDB=“off”
GOTMPDIR=“”
GOTOOLDIR=“/usr/local/opt/go/libexec/pkg/tool/darwin_amd64”
GOVCS=“”
GOVERSION=“go1.20.5”
GCCGO=“gccgo”
GOAMD64=“v1”
AR=“ar”
CC=“cc”
CXX=“c++”
CGO_ENABLED=“1”
GOWORK=“”
CGO_CFLAGS=“-g -O2 -I./include”
CGO_CPPFLAGS=“”
CGO_CXXFLAGS=“-O2 -g”
CGO_FFLAGS=“-O2 -g”
CGO_LDFLAGS=“-O2 -g”
PKG_CONFIG=“pkg-config”
GOGCCFLAGS=“-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/x3/y2ym0_kn7031b383bgnkp07h0000gn/T/go-build1263901041=/tmp/go-build -gno-record-gcc-switches -fno-common”

Hi @zshwei, welcome to the forum.

What error message do you get?

Thanks very much.

Sorry. Forgot to attach the compiling error. Here is it.

Could you, please, try to run this without linking ./include?
CGO_CFLAGS=“-O2 -g” go build

1 Like

@crivic @christophberger This issue was resolved, the root causes is my company’s stupid auto-encryption policy. Thank you very much!

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.