I have a ‘legal’ requirement to build a Go module to produce an executable and all of its dependencies as a single .so. The exe contains our private Go code and dynamically link to open source packages as as single .so
I am using Go 1.12.7 with GO111MODULE=on on SLES12
Very much appreciate any advice
Wouldn’t it be what you’re looking for ? http://snowsyn.net/2016/09/11/creating-shared-libraries-in-go/
Have a nice day.
I saw that post as well, and it not making sense to me may be you can show a way to create a shared lib ( .so) against downloaded dependencies under GOPATH/pkg/mod?
Note, i am build my app with GOMOD
Ok, I don’t know what could be messed with gomod but in first place, I would follow this article just to check what happens. So I’d follow the instructions given :
As you can see, the code has to be part of the
main package, with an empty
main function. The
C package has to be imported. Exported functions must have the
And then build with
go build -o libimgutil.so -buildmode=c-shared yourfile.go
Could you try that ?
wow, I am able to build my .so file at my module dir ( the one with go.mod)
go build -o libthirdparty.so -buildmode=c-shared
it creates a .so file with about 60M.
Now I need to produce my executable which i expect to be small
Any help is very much appreciated
just want to ping this group again, is there a way for me to build my own Go source and dynamically link to my thirdparties package produce by c-shared?
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.