Closed hbakhtiyor closed 5 years ago
You won't be able to build with CGO_ENABLED=0
as this library is a C wrapper around openssl.
If you want to do a static build, try also adding the -tags openssl_static
argument to go build
. If you still get a failure, add -x
and paste the resulting output.
go build -a -ldflags '-extldflags "-static"' -tags openssl_static
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x11): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-534046751/000004.o: In function `_cgo_18049202ccd9_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:49: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(b_sock.o): In function `BIO_gethostbyname':
(.text+0x71): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
go build -a -x -ldflags '-extldflags "-static"' -tags openssl_static
https://gist.github.com/hbakhtiyor/5bc6f3de247302151bce393dc31e3731
It looks like you are having problems linking in glibc. Perhaps try statically linking in a different libc. Unfortunately, the details on how to do that are outside of the scope of this project.
getting error while running this command
CGO_ENABLED=0 GOOS=linux go build
go build -a -ldflags '-extldflags "-static"'
without env and build static link binary