I find the package you build with 'go build buildmode=c-archive/c-shared', when you build you code with the lib, the outer need to have main func, I don't know why.
在 2016年5月18日星期三 UTC+8上午11:11:57,Justin Israel写道: > > I'm wondering if someone can tell me if this is either a limitation of > buildmode=c-archive static libs, or if I am really just doing something > wrong. > > Problematic steps: > > 1. export functions to libgofoo.a using buildmode=c-archive > 2. statically link libgofoo.a into another library to produce libfoo.a > 3. Someone else consumes libfoo.a and libgofoo.a in their library, and > get linker errors about: > ld: libgofoo.a(go.o): relocation R_X86_64_TPOFF32 against > `runtime.tlsg` can not be used when making a shared object; recompile with > -fPIC > libgofoo.a: could not read symbols: Bad value > > But library that wants to consume these libs can do so if they dynamically > link with shared libs from c-shared. Also, if the consumer of the libs is > a main binary, then the static linking works and does not complain. It is > only when the target is a library. > > I could swear I went through and ensured -fPIC was being used, but it > didn't seem to make a difference. Am I infact just messing up my > compilation settings and failing to add this flag as it suggests, or is > there a known limitation related to the steps I have outlined? > > Thanks! > Justin > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2032198a-00dd-40a8-a8aa-489e9ae406bf%40googlegroups.com.
