Thanks. It works perfectly !

> On 18 Oct 2020, at 00:55, Ian Lance Taylor <i...@golang.org> wrote:
> 
> On Sat, Oct 17, 2020 at 12:25 PM Thierry Fournier
> <thierry.f...@gmail.com> wrote:
>> 
>> I need to build go with an archive file which requires to be linked with the 
>> option "-Wl,--whole-archive" on linux or "-Wl,-all_load" on macos.
>> 
>> My go file contains this code:
>> 
>> /*
>> 
>> #cgo darwin LDFLAGS: -L.. -Wl,-all_load -lmy_lib
>> #cgo linux LDFLAGS: -L.. -Wl,--whole-archive -lmy_lib
>> 
>> */
>> import "C"
>> 
>> When I try to compile on Linux or Mac, this doesn't work. I read these 
>> errors:
>> 
>> Mac:
>> 
>> go build _/Users/thierryfournier/git/my-lib/my_lib: invalid flag in #cgo 
>> LDFLAGS: -Wl,-all_load
>> 
>> Linux:
>> 
>> go build _/home/thierry/my_lib/my_lib: invalid flag in #cgo LDFLAGS: 
>> -Wl,--whole-archive
>> 
>> I test the local link on both OS, and the option exists and works for c.
>> 
>> So, i don’t found any way to embed the whole library.
>> 
>> I don’t find a way to understand how the linker is called
>> I don’t find documentation about supported flag.
>> 
>> If anyone has a solution or a clue, it will be welcome
> 
> Add these flags to the CGO_LDFLAGS_ALLOW environment variable.
> 
> You may want to file an issue to get them added to the list of permitted 
> flags.
> 
> Ian

-- 
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/5F66338B-50B3-47B3-A2EC-0A537F04EB5C%40gmail.com.

Reply via email to