keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Go bindings static library issues (can't compile static go binary with static library)

Open guitmz opened this issue 7 years ago • 2 comments

Hi, when I use the shared library and compile my golang binary dynamically, everything seems to work but I can't say the same for when I try to build it statically (using the static library).

Build command:

$ go build -a -ldflags '-s -w -extldflags "-static"' main.go

Output is very big, I included it here: https://paste.ee/p/heO51

OS: tried on Centos 7, Debian 9 and MacOS High Sierra

kstool works fine by the way (either with shared or static library).

At this point I'm not sure if I'm dumb or if there is anything wrong, so I appreciate if anyone could shed some light here.

Thanks!

guitmz avatar Jul 11 '18 12:07 guitmz

Hi guitmz,

I've got the same output when trying to compile go keystone binding sample and I think I've managed to find out what the issue is here:

  • the C sample uses KEYSTONE_LDFLAGS = -lkeystone -lstdc++ -lm in the Makefile
  • the keystone go binding has // #cgo LDFLAGS: -lkeystone in the keystone-binding.go

I've managed to resolve the issue by executing: export CGO_LDFLAGS="-lkeystone -lstdc++ -lm"

turekt avatar Aug 02 '19 13:08 turekt

@turekt super! I will test it as soon as possible, thanks a lot, it makes sense

guitmz avatar Aug 09 '19 09:08 guitmz