cgo: Duplicate definitions when linking

13 views
Skip to first unread message

Albert Strasheim

unread,
Dec 9, 2010, 7:38:16 AM12/9/10
to golang-dev
Hello all

I am playing with the new cgo.

Consider the case where you have two packages, pkg1 and pkg2, that
both call the same C function in the same library.

If a binary imports both packages, you get an error at link time:

pkg2.a(pkg2.cgo2.o): duplicate definition of _cgo_Cfunc_somefunc

Maybe this falls under the "don't do that" category, but I can think
of cases where you might want to do this, e.g., wrapping a big C
library as multiple packages and calling some general C code from all
the subpackages.

rsc?

Regards

Albert

Russ Cox

unread,
Dec 9, 2010, 10:14:57 AM12/9/10
to Albert Strasheim, golang-dev
So the issue is that two different libraries have
chosent to wrap, say, C.strtol?

Okay, please file a bug.

Russ

Reply all
Reply to author
Forward
0 new messages