SWIG+;Go:不支持动态符号的重新定位 我试图用SWIG在GO中包装C++库,但自从升级到1.4.2.0/P>后,我尝试使用包时会产生构建错误。

SWIG+;Go:不支持动态符号的重新定位 我试图用SWIG在GO中包装C++库,但自从升级到1.4.2.0/P>后,我尝试使用包时会产生构建错误。,go,swig,Go,Swig,该软件包可在以下位置找到: 它包含.SWigCxx文件以及C++头文件。作为参考,我正在尝试与此库交互: 按照SWIG网站上的说明,我能够构建我的软件包并将其安装到我的机器上。我不知道如何自动读取.swigcxx文件并构建包,所以我不得不添加一个Makefile,手动调用所有命令 但是,库的构建和安装没有错误。在Go 1.3.3中,我也可以毫无问题地使用该软件包。但是,在Go 1.4.2中运行相同的程序会导致许多生成错误 我的测试程序: package main import ( "

该软件包可在以下位置找到:

它包含.SWigCxx文件以及C++头文件。作为参考,我正在尝试与此库交互:

按照SWIG网站上的说明,我能够构建我的软件包并将其安装到我的机器上。我不知道如何自动读取.swigcxx文件并构建包,所以我不得不添加一个Makefile,手动调用所有命令

但是,库的构建和安装没有错误。在Go 1.3.3中,我也可以毫无问题地使用该软件包。但是,在Go 1.4.2中运行相同的程序会导致许多生成错误

我的测试程序:

package main

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

func main() {
    x := goewah.NewEWAHBoolArray()
    x.Set(1)
    x.Set(2)
    fmt.Println(x.Get(1))
}
我在尝试构建时看到的错误:

# command-line-arguments
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_sizeInBits: unsupported  relocation for dynamic symbol _wrap_EWAHBoolArray_sizeInBits (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_isEmpty: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_isEmpty (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_toIntArray: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_toIntArray (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_numberOfOnes: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_numberOfOnes (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_readStr: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_readStr (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_writeStr: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_writeStr (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_read__SWIG_1: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_read__SWIG_1 (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_read__SWIG_0: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_read__SWIG_0 (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_write__SWIG_1: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_write__SWIG_1 (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_write__SWIG_0: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_write__SWIG_0 (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_reset: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_reset (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_logicalandnot: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_logicalandnot (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_logicalxor: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_logicalxor (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_logicalor: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_logicalor (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_logicaland: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_logicaland (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_inplace_logicalnot: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_inplace_logicalnot (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_logicalnot: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_logicalnot (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_set: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_set (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_get: unsupported relocation for dynamic symbol _wrap_EWAHBoolArray_get (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_new_EWAHBoolArray: unsupported relocation for dynamic symbol _wrap_new_EWAHBoolArray (type=1 stype=32)
bitbucket.org/evanh/goewah._wrap_EWAHBoolArray_get: unhandled relocation for _wrap_EWAHBoolArray_get (type 32 rtype 1)
too many errors

我明白了。我还必须链接到C库。修正了下面的代码

package main

//#cgo LDFLAGS: -L/usr/local/lib -lewah
import "C"

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

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

什么操作系统?这也是我在优胜美地操作系统上测试的。我也将添加到这里,谢谢。这里有一个纯Go实现