| ▲ | johnisgood 4 days ago | |
I use `-ldflags '-extldflags "-static"` as well. From the .go file, you just do `// #cgo LDFLAGS: -L. -lfoo`. You definitely do not need Alpine Linux for this. I have done this on Arch Linux. I believe I did not even need musl libc for this, but I potentially could have used it. I did not think I was doing something revolutionary! In fact, let me show you a snippet of my build script:
And like I said, the .go file in question has this:
It works perfectly, and should work on any Linux distribution. | ||
| ▲ | mmulet 3 days ago | parent [-] | |
I use alpine for this [1] reason, but I will admit that this is a premature-optimization. I haven’t actually ran into the problem myself. —— Your code is great, I do basically the same thing (great minds think alike!). The only thing I want to add is that cgo supports pkg-config directly [2] via
So you don’t have to pass in linker flags manually. It’s incredibly convenient.[1]https://stackoverflow.com/questions/57476533/why-is-statical... [2]https://github.com/mmulet/term.everything/blob/def8c93a3db25... | ||