Open tenox7 opened 5 years ago
Hmm I'm not too sure, but perhaps it is possible if we compile SDL2 from source using musl-gcc
?
Perhaps doesn't have to be with musl, but just static.
I can still reproduce the issue.
$ CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=amd64 go build -tags static -ldflags "-s -w"
$ ldd guitest
linux-vdso.so.1 (0x00007fffba277000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8355263000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f835525d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f835523b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8355051000)
/lib64/ld-linux-x86-64.so.2 (0x00007f83553da000)
Is there a way to compile with static libs?
Hi @gcstr, I believe SDL2 is compiled with glibc which is why it can't be fully static. I could be wrong though.
Do you have a specific issue that is caused by this behavior?
UPDATE: It seems like SDL2 can be compiled statically. I will investigate how to accomplish that.
Sorry, I couldn't figure out how to make it completely static. The sdl2-config --static-libs
command still defines some dynamic libraries though they should be available on most Linux platform.
$ sdl2-config --static-libs
-L/usr/local/lib -lSDL2 -Wl,--no-undefined -lm -ldl -lpthread -lrt
If anyone knows how to make it completely static, please let me know!
@gcstr It is not really recommended to build a fully static binary with Glibc, you will get a big fat warning from Glibc, and you will have issues with Alsa, which is hard to compile statically (probably some patches are needed).
If you really want this, you need to use musl
toolchain to build SDL and all dependencies fully static, and again apply some patches to Alsa (probably Alpine distro have some). Also, Musl recommends linking libC statically, with Glibc you get a warning not to do that.
I tried using
-extldflags "-static"
but that produces a binary that either crashes or hangs forever. It could be something to do with Alsa lib.Would it be possible to support fully statically linked binaries?