Re: [go-nuts] Statically linking cgo
Try this? http://blog.madewithdrew.com/post/statically-linking-c-to-go/ On Sat, Dec 24, 2016 at 6:58 PM Justin Israelwrote: > > > On Sun, Dec 25, 2016, 2:43 PM James Pettyjohn > wrote: > > Hi Justin, > > Thanks for the holiday reply. > > The ultimate goal in this was deployment into docker as a self contained > binary, no dynamic library dependencies and no parent image. The most > common solution to this I've seen is disable CGO altogether but with the > libraries I'm using this is not an option at this time. > > > Right. But you still need cgo for the C dependency so there is no way to > disable it. You can only statically link as much as possible. I can't > confirm right now but I think that may still leave you with a libc dynamic > link at the very least > > > > Best, > James > > On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote: > > > > On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn > wrote: > > I've been looking at a number of articles on statically linking go files > by disabling CGO, sounds great except I've got a libsass dependency until > the native libsass is ready. > > Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)? > > > Are you asking about statically linking libsass? > > In addition to other flags to statically link your Go binary, you can tell > cgo to statically link libsass: > > $ export CGO_LDFLAGS="\ > -Wl,-Bstatic \ > `pkg-config --libs libsass` \ > -lotherDep -lotherDep2 > -Wl,-Bdynamic" > > > > - Justin > > -- > 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...@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Statically linking cgo
On Sun, Dec 25, 2016, 2:43 PM James Pettyjohnwrote: > Hi Justin, > > Thanks for the holiday reply. > > The ultimate goal in this was deployment into docker as a self contained > binary, no dynamic library dependencies and no parent image. The most > common solution to this I've seen is disable CGO altogether but with the > libraries I'm using this is not an option at this time. > Right. But you still need cgo for the C dependency so there is no way to disable it. You can only statically link as much as possible. I can't confirm right now but I think that may still leave you with a libc dynamic link at the very least > Best, > James > > On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote: > > > > On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn > wrote: > > I've been looking at a number of articles on statically linking go files > by disabling CGO, sounds great except I've got a libsass dependency until > the native libsass is ready. > > Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)? > > > Are you asking about statically linking libsass? > > In addition to other flags to statically link your Go binary, you can tell > cgo to statically link libsass: > > $ export CGO_LDFLAGS="\ > -Wl,-Bstatic \ > `pkg-config --libs libsass` \ > -lotherDep -lotherDep2 > -Wl,-Bdynamic" > > > > - Justin > > -- > 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...@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Statically linking cgo
Hi Justin, Thanks for the holiday reply. The ultimate goal in this was deployment into docker as a self contained binary, no dynamic library dependencies and no parent image. The most common solution to this I've seen is disable CGO altogether but with the libraries I'm using this is not an option at this time. Best, James On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote: > > > > On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn> wrote: > >> I've been looking at a number of articles on statically linking go files >> by disabling CGO, sounds great except I've got a libsass dependency until >> the native libsass is ready. >> >> Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)? >> > > Are you asking about statically linking libsass? > > In addition to other flags to statically link your Go binary, you can tell > cgo to statically link libsass: > > $ export CGO_LDFLAGS="\ > -Wl,-Bstatic \ > `pkg-config --libs libsass` \ > -lotherDep -lotherDep2 > -Wl,-Bdynamic" > > > > - Justin > >> -- >> 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...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Statically linking cgo
On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohnwrote: > I've been looking at a number of articles on statically linking go files > by disabling CGO, sounds great except I've got a libsass dependency until > the native libsass is ready. > > Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)? > Are you asking about statically linking libsass? In addition to other flags to statically link your Go binary, you can tell cgo to statically link libsass: $ export CGO_LDFLAGS="\ -Wl,-Bstatic \ `pkg-config --libs libsass` \ -lotherDep -lotherDep2 -Wl,-Bdynamic" - Justin > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.