building go 1.20.1 to C for use in Nodejs

87 views
Skip to first unread message

David Choi (jsoneaday)

unread,
Feb 23, 2023, 4:18:38 PM2/23/23
to golang-nuts
Hi I'm trying to build my project as C so I can call it from Nodejs. But when I run the command "go build -buildmode=c-shared -o keyring.so ." I get a so file but no h C header.

I am running this on Mac M1. I read something about cgo being disabled by default on mac's without the c toolchain but I do have gcc installed so not sure what's up.

Ian Lance Taylor

unread,
Feb 23, 2023, 5:56:08 PM2/23/23
to David Choi (jsoneaday), golang-nuts
You will only get a C header file if your code uses //export to export
some functions to be callable from C code.

If you are doing that already, show us a small self-contained example
that we can use to recreate the problem. Thanks.

Ian
Reply all
Reply to author
Forward
0 new messages