How to embed C dynamic libraries into Go binary

71 Views Asked by At

I have a Golang project which uses some C libraries from another team in my company which come with shared objects and would be very difficult to compile statically. I would like to keep the binary for my project portable, so I want to use import "embed" to keep the shared objects in the binary and then dump them into a temp dir when the program starts, but before the C part of my project loads.

I can probably compile the part of my project that uses the C code into a Go plugin and then doing all the embed stuff in the main binary before it loads that plugin, but I feel like there's an easier way that I'm missing.

Is there any way to stop Go from trying to load C dynamic libraries before I unpack them? Or maybe on the C side stop it from trying to load them so early?

0

There are 0 best solutions below