Following steps from https://blog.ralch.com/articles/golang-sharing-libraries/
.
├── _wale.c
└── nautilus.go
go build -buildmode=c-archive -o nautilus.a nautilus.go
.
├── _wale.c
├── nautilus.a
├── nautilus.go
└── nautilus.h
These two wont compile without -lpthread
but when they do, they work!
gcc -o _wale _wale.c nautilus.a -lpthread
./_wale # works!
aarch64-linux-gnu-gcc -static -o _wale _wale.c nautilus.a -lpthread
./_wale # works!
zig cc -static -o _wale _wale.c nautilus.a
./_wale # hangs and segfaults
zig cc -static -o _wale _wale.c nautilus.a -lpthread
./_wale # hangs and segfaults
zig cc -o _wale _wale.c nautilus.a
./_wale # hangs and segfaults
zig cc -o _wale _wale.c nautilus.a -lpthread
./_wale # hangs and segfaults
Above examples are more simple but what I'm really tring to do is:
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC="${PWD}/zigcc" go build -a -ldflags "-linkmode external -extldflags '-stati
c' -s -w" -buildmode=c-archive -o nautilus.a nautilus.go
zig cc -static -o _wale _wale.c nautilus.a
And really I want to write a zig application that uses this C library. I dropped back to zig compiled C to see what was broken without zig syntax learning in the way.