I have a program entirely written in C that uses multiple object (.o)
files in it. These files are all packed inside an archive file (.a)
which, in
There currently isn't a supported way to do what you want. Go always needs the support of its runtime, and the entry point for that is always main
. AFAIK, gccgo also makes these same assumptions, and doesn't provide a way to easily link into from other programs.
If you want to do this in a supported manner, you will have to wait until go1.5+ where work is being done to compile shared libraries from Go code.
If you really want to hack on this now, you can look into how the Android port works using the default gc toolchain with -linkmode external
, which renames main
in the object file and calls it externally.