weaver icon indicating copy to clipboard operation
weaver copied to clipboard

Missing stdlib.h

Open KadoBOT opened this issue 1 year ago • 6 comments

Failed to install weaver: Missing stdlib.h

Which I managed to get around by using the following: export CGO_ENABLED=1; export CC=gcc; go install github.com/ServiceWeaver/weaver/cmd/weaver@latest. Not sure if it's worth mentioning this somewhere in the docs... Cheers!

go install github.com/ServiceWeaver/weaver/cmd/weaver@latest

go: downloading github.com/ServiceWeaver/weaver v0.1.1
go: downloading github.com/google/cel-go v0.12.5
go: downloading github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
go: downloading google.golang.org/genproto v0.0.0-20221109142239-94d6d90a7d66
go: downloading go.opentelemetry.io/otel/trace v1.13.0
go: downloading golang.org/x/exp v0.0.0-20230206171751-46f607a40771
go: downloading go.opentelemetry.io/otel v1.13.0
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.1
go: downloading github.com/mattn/go-sqlite3 v1.14.16
go: downloading go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0
# github.com/mattn/go-sqlite3
../../../go/pkg/mod/github.com/mattn/[email protected]/backup.go:14:10: fatal error: 'stdlib.h' file not found
#include <stdlib.h>
         ^~~~~~~~~~
1 error generated.

Go env:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/[HIDDEN]"
GOENV="/Users/[HIDDEN]"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/[HIDDEN]"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/[HIDDEN]"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.3/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="[HIDDEN]"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f7/pzdxngcx2cl4lm0xk722f3dr0000gr/T/go-build96214606=/tmp/go-build -gno-record-gcc-switches -fno-common"

KadoBOT avatar Mar 02 '23 04:03 KadoBOT

It would be worthwhile to provide more information about your environment, so that someone can try and reproduce or provide advice.

The output of go env might be a good start.

slewiskelly avatar Mar 02 '23 05:03 slewiskelly

Thanks @slewiskelly, I have updated the description with the output of the go env

KadoBOT avatar Mar 02 '23 11:03 KadoBOT

@KadoBOT You probably missing xcode Command Line Tools under the MAC, so https://github.com/mattn/go-sqlite3 cannot be successfully installed

sumkincpp avatar Mar 02 '23 11:03 sumkincpp

@sumkincpp It wasn't the case for me. I even did a xcode-select --install to make sure, and got the same error. What's fixed for me was the input I provided in the description.

KadoBOT avatar Mar 02 '23 11:03 KadoBOT

Yes, by setting the export CC=gcc flag which sets the right C compiler to use for building the binary which also includes the standard libraries. If GCC is installed properly this issue may not arise at all.

iamvasanth07 avatar Mar 02 '23 12:03 iamvasanth07

Thanks for reporting. May be similar to this issue filed against Golang: https://github.com/golang/go/issues/39232

Not sure there's anything we can do other than point it out in our installation guide. We may also look at using non-CGO alternatives to sqlite.

spetrovic77 avatar Mar 02 '23 16:03 spetrovic77

For the cgo free sqlite driver, have a look at https://pkg.go.dev/modernc.org/sqlite

breml avatar Mar 03 '23 19:03 breml

Ooh, that's awesome. We'll try it out and make the switch.

On Fri, Mar 3, 2023 at 11:02 AM Lucas Bremgartner @.***> wrote:

For the cgo free sqlite driver, have a look at https://pkg.go.dev/modernc.org/sqlite

— Reply to this email directly, view it on GitHub https://github.com/ServiceWeaver/weaver/issues/79#issuecomment-1453979529, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJSQ6SJB3INGJ4FMM3YFWTW2I525ANCNFSM6AAAAAAVM3VK2Y . You are receiving this because you were assigned.Message ID: @.***>

spetrovic77 avatar Mar 03 '23 19:03 spetrovic77

@breml This is not a license I'm familiar with, unfortunately. Go seems to think it's okay, you think therefore it's okay to link to? https://gitlab.com/cznic/sqlite/-/blob/v1.21.0/LICENSE

spetrovic77 avatar Mar 03 '23 21:03 spetrovic77

By a quick check to me, this looks like a BSD 3-Clause “New” or “Revised” License or similar. That being said, I am not a lawer nor a specialist in licensing and I did not perform a word by word comparison.

breml avatar Mar 03 '23 21:03 breml

We added a note about this issue in the installation section. Thank you all for checking and the fix.

rgrandl avatar Mar 03 '23 22:03 rgrandl