Friday, May 27, 2016

Return of the static

While working on some go code recently, I hit a problem which was a bit perplexing:

# command-line-arguments
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
/usr/lib/golang/pkg/tool/linux_amd64/6l: running gcc failed: unsuccessful exit status 0x100

After some consideration, and examination of the go command
go build -v -ldflags '-extldflags '\''-static'\'' -X' -o pkg/xxxx-linux-amd64 main.go
I remembered a change to do with the packaging of static libraries, that is, they are not installed by default on RHEL/CentOS.
A simple
yum install glibc-static
was all that was required


  1. Great work. Truly speaking I never seen a blog like that. Absolutely superb work. Good luck. Thanks for such an informative post. For more information visit k2 incense