user720694
user720694

Reputation: 2075

C source files not allowed when not using cgo or SWIG

I am using Go 1.6 on OSX 10.11.4 and trying to cross compile my go program for windows and linux. I use a library (https://github.com/pebbe/zmq4) in my go program which is a Go binding for a C based implementation. I followed the instructions to cross compile for x86 windows as listed here by issuing the following command:

env GOOS=windows GOARCH=386 go build -v znode.go

However the above command gives me the following error

znode.go:15:2: C source files not allowed when not using cgo or SWIG: dummy.c

Is there a workaround for this? I saw other posts on stackoverflow which suggest moving to go1.5 but i am already on go1.6

Upvotes: 2

Views: 1651

Answers (1)

Joe Abbate
Joe Abbate

Reputation: 1750

FWIW after six years ... user720694's comment has the clue. If there are any .c or .cpp/cc/etc. files in the build directory, adding CGO_ENABLED=0 before go build does the trick.

Upvotes: 3

Related Questions