Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: SWIG + Go: unsupported relocation for dynamic symbol #10919

Closed
evanh opened this issue May 20, 2015 · 1 comment
Closed

cmd/cgo: SWIG + Go: unsupported relocation for dynamic symbol #10919

evanh opened this issue May 20, 2015 · 1 comment

Comments

@evanh
Copy link

evanh commented May 20, 2015

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. SWIG Version 3.0.5.

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:

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
@evanh
Copy link
Author

evanh commented May 20, 2015

I figured this out. I had to link against the C library as well.

Fixed code:

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

@evanh evanh closed this as completed May 20, 2015
@mikioh mikioh changed the title SWIG + Go: unsupported relocation for dynamic symbol cmd/cgo: SWIG + Go: unsupported relocation for dynamic symbol May 21, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants