Problem with exports in archive (GCCGO)

50 views
Skip to first unread message

Jiří Zárevúcky

unread,
Jul 18, 2012, 9:43:02 AM7/18/12
to golan...@googlegroups.com
Hello fellow gophers,
I've been trying to build a library by hand (without go tool, I can't use it in my environment).
For gccgo to find exports, I compile all the .go files to .o, extract exports to .gox files, and package all the .gox to libsomething.a, which then resides in import directory.

The problem is that when I try importing the package, I get an error that states a redeclaration of the package once for every .gox file in the archive (maybe minus one, I didn't count precisely, just tried packing less .gox files to verify).

If this is a bug, how do I report it to GCCGO authors?
If it's not a bug, what is the proper way to generate exports from object files?

Ian Lance Taylor

unread,
Jul 18, 2012, 9:46:27 AM7/18/12
to Jiří Zárevúcky, golan...@googlegroups.com
It's not clear to me whether all the .go files are in the same package or not.

If they are all in the same package, you should pass all the .go files
to gccgo at the same time:
gccgo -c a.go b.go c.go

If they are not in the same package, then you need to use multiple
import statements, and those import statement should refer to the .gox
files rather than the .a file.

Ian

Jiří Zárevúcky

unread,
Jul 18, 2012, 10:07:43 AM7/18/12
to golan...@googlegroups.com


On Wednesday, 18 July 2012 15:46:27 UTC+2, Ian Lance Taylor wrote:

It's not clear to me whether all the .go files are in the same package or not.

If they are all in the same package, you should pass all the .go files
to gccgo at the same time:
    gccgo -c a.go b.go c.go


Ah, right.
Something I did earlier seems to have confused me into thinking gccgo only emits code for the first file on the command line with -c.  Now that I tried it again I see this assumption is false.
Sorry about the fuss.
Reply all
Reply to author
Forward
0 new messages