我正在尝试使用SWIG将C ++ example暴露给Go,
我这样做:
swig -intgosize 64 -go example.i
go tool 8g -+ example.go
eval $(go env) # fill in the appropiate vars
go tool 8c -I ${GOROOT}/pkg/${GOOS}_${GOARCH} -D _64BIT=1 -v example_gc.c
go tool pack grc example.a example.8 example_gc.8
export DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH
g++ -O2 -fPIC -march=nocona -c example_wrap.c
g++ -O2 -fPIC -march=nocona -c example.c
gcc -shared -o example.so example_wrap.o example.o
##g++ -dynamclib example.o example_wrap.o -o example.so
go tool 8g runme.go
go tool 8l -o runme runme.8
除了最后一行之外的所有行都有效,但是在我得到的最后一个命令中:
/go/simple/example.Void.Swigcptr: /go/simple/example.a(example.8): go%2ebuiltin.error.Error: redefinition
go.importpath.runtime/cgo.(0): not defined
type./go/simple/example.Void(0): not defined
/go/simple/example.gclocals·3(0): not defined
/go/simple/example.gcargs·3(0): not defined
go.string."Swigcptr"(0): not defined
go.string."SwigcptrVoid"(0): not defined
go.string."example"(0): not defined
type.*/go/simple/example.SwigcptrVoid(0): not defined
/go/simple/example.gclocals·2(0): not defined
/go/simple/example.gcargs·2(0): not defined
type./go/simple/example.SwigcptrVoid(0): not defined
/go/simple/example.gclocals·1(0): not defined
/go/simple/example.gcargs·1(0): not defined
/go/simple/example.gclocals·0(0): not defined
/go/simple/example.gcargs·0(0): not defined
由于