Hi,
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
Thanks,
Thierry