Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

build

swig

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))
}
like image 479
Evan Hicks Avatar asked May 14 '15 22:05

Evan Hicks


1 Answers

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

package p
import "C"

and you should get around it.

like image 171
iant Avatar answered Oct 19 '22 23:10

iant