dscojuxf69080 2015-05-20 17:37
浏览 53

SWIG + Go:动态符号不受支持的重定位

I'm trying to wrap a C++ library in Go using SWIG, but I'm getting build errors when I try to use the package since I upgraded to Go 1.4.2.

The package can be found here: https://bitbucket.org/evanh/goewah

It contains the .swigcxx file as well as the C++ headers. For reference, I'm trying to interface with this library: https://github.com/lemire/EWAHBoolArray

Following the instructions on the SWIG website, I'm able to build my package and have it install on my machine. I couldn't figure out how to get Go to automatically read my .swigcxx file and build the package, so I had to add a Makefile that called all the commands manually.

However, the library builds and installs without errors. On Go 1.3.3, I could also use the package with no problems. However, running the same program in Go 1.4.2 causes a number of build errors.

My test program:

package main

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

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

The errors I see when I try to go build it:

# 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
  • 写回答

1条回答 默认 最新

  • dpowhyh70416 2015-05-20 20:01
    关注

    Figured it out. I had to link against the C library as well. Fixed code below.

    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))
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法