英文:
SWIG + Go: C source files not allowed when not using cgo
问题
我正在尝试使用SWIG将这个库(https://github.com/lemire/EWAHBoolArray)包装到Go中,但自从我升级到1.4版本后遇到了很多问题。
在使用Go 1.3.3并按照SWIG网站上的SWIG + Go的说明进行操作后,我成功地使一切正常工作。我不得不手动编译和安装包,而不是使用go build,但一切都正常。
现在,当我尝试使用Go 1.4.2运行相同的程序时,我遇到了以下错误:
ewah_usage.go:5:2: 在不使用cgo时不允许使用C源文件:goewah_gc.c
我使用最新的SWIG和最新的Go重新构建了该包,并且似乎已经正确安装。但是每当我运行使用该库的程序时,都会出现上述错误。
我的测试程序(goewah是我使用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))
}
英文:
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))
}
答案1
得分: 17
这是一个错误。抱歉。添加一个只包含以下内容的文件:
package p
import "C"
这样你应该能够解决这个问题。
英文:
It's a bug. Sorry. Add a file that just says
package p
import "C"
and you should get around it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论