gobuildswig

SWIG + Go: C source files not allowed when not using cgo


I am trying to wrap this library (https://github.com/lemire/EWAHBoolArray) in Go using SWIG, but I'm having a lot of problems since I upgraded to 1.4

I had successfully gotten everything to work using Go 1.3.3 and following the instructions on the SWIG site for SWIG + Go. I had to compile and install the package manually instead of using go build, but everything was working fine.

Now, when I try to run the same program with Go 1.4.2, I get this error:

ewah_usage.go:5:2: C source files not allowed when not using cgo: goewah_gc.c

I rebuilt the package using the latest SWIG and the latest Go, and it seems to have installed correctly. But whenever I run a program using the library, I get the above error.

My test program (goewah is the library I built with SWIG)

package main

import (
    "fmt"
    "bitbucket.org/evanh/goewah"
)

func main() {
    x := goewah.NewEWAHBoolArray()
    x.Set(1)
    x.Set(2)
    fmt.Println(x.Get(1))
}

Solution

  • It's a bug. Sorry. Add a file that just says

    package p
    import "C"
    

    and you should get around it.