thank you~I got it.

在 2019年8月28日星期三 UTC+8上午11:59:42,Justin Israel写道:
>
>
>
> On Wed, Aug 28, 2019, 3:47 PM <w1252...@gmail.com <javascript:>> wrote:
>
>> 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.
>>
>
> That requirement is documented here:
> https://golang.org/cmd/go/#hdr-Build_modes
>
>
>> 在 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 a topic in the 
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/golang-nuts/EhndTzcPJxQ/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> golan...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/2032198a-00dd-40a8-a8aa-489e9ae406bf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/2032198a-00dd-40a8-a8aa-489e9ae406bf%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/908b8c77-5315-4806-b9a9-dc89cdba8902%40googlegroups.com.

Reply via email to