Error cgo: cannot parse $WORK/b003/_cgo_.o as ELF, Mach-O, PE or XCOFF

Hello I am running the build command below. I’m trying to create a C module that will run in Nodejs. I am using napi-go to do this.

CGO_LDFLAGS_ALLOW=-Wl,-no_pie GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -buildmode=c-shared -o "example.node" -a ./cmd

Hi, Jsoneaday,

Can you send a link to “go-napi” and to the code you’re tring to compile? Is there any more output information from the build process that you can include?

1 Like

I think this third party lib that I was using napi-go was causing problems so I’m doing it with node-addon-api now. Still having issues but I was able to get the header and .so files generating using this command

go build -trimpath -buildmode=c-shared -ldflags '-w -s -extldflags "-lresolv"' -o ./src/go

The lresolv at the end was the big one I needed.

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