You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to build a static binary using musl so it can be run in alphine:
CC=musl-gcc CGO_ENABLED=1 go build -a -ldflags '-linkmode external -extldflags "-static"' -o gowebserver main.go
# github.com/h2non/bimg
../../go/pkg/mod/github.com/h2non/[email protected]/metadata.go:5:10: fatal error: vips/vips.h: No such file or directory
5 | #include "vips/vips.h"
| ^~~~~~~~~~~~~
compilation terminated.
I also attempted with gcc:
CC=gcc CGO_ENABLED=1 go build -a -ldflags '-linkmode external -extldflags "-static"' -o gowebserver main.go
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lvips: No such file or directory
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.c.o): in function `g_get_user_database_entry':
(.text+0x29f): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0xe0): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0x11e): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-4234432590/000004.o: in function `_cgo_9c8efe9babca_C2func_getaddrinfo':
/tmp/go-build/cgo_unix_cgo.cgo2.c:58:(.text+0x37): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Building a normal binary works fine, but it doesn't suit my usecase: go build -o gowebserver main.go
My final goal is to run this go binary inside a docker alpine container.
musl-gcc --version
x86_64-linux-gnu-gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc
Version
gcc --version
gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The text was updated successfully, but these errors were encountered:
I tried to build a static binary using musl so it can be run in alphine:
I also attempted with gcc:
Building a normal binary works fine, but it doesn't suit my usecase:
go build -o gowebserver main.go
My final goal is to run this go binary inside a docker alpine container.
Vips
Location
Version
OS
Ubuntu 23.10 x86_64 6.5.0-14-generic
Go
Version
musl
Version
gcc
Version
The text was updated successfully, but these errors were encountered: