4 ms·
Pretty please, tell me how to compile static binaries and I’ll do that forever. I always end up with certain external libraries still being required.
by Wowfunhappy 6y ago
Pretty please, tell me how to compile static binaries and I’ll do that forever. I always end up with certain external libraries still being required.
- hctaw 6y agoYou need to compile a static executable (not with static libraries, there's a subtle difference). The flags depend on your compiler. If you're on Linux, musl libc and musl-tools are useful for dealing with this reliably.
- a1369209993 6y ago> You need to compile a static executable This is functionally impossible on $ISA-linux-gnu, because the glibc developers refuse to provide a working C standard library (libc.a). > musl libc and musl-tools are useful Sure, but if the software worked (/reliably) with musl, we'd be using that already.
- jart 6y agoUse Cosmopolitan Libc. Everything is statically linked. See for example https://justine.lol/redbean/index.html https://justine.lol/redbean/index.html don't you want binaries like that?
- PaulDavisThe1st 6y agoStep 3b is to make sure you don't use libraries that themselves cannot be fully statically linked (hello, GTK!). It's cool that they use run-time dynamic loading to "modularize" certain features (such as image loading), but it seriously damages the benefits of static linkage.
- nh2 6y agoGTK can be statically linked. Example executable: https://github.com/nh2/static-haskell-nix/releases/tag/c-static-gtk3-apps-button-example-2020-11-23 https://github.com/nh2/static-haskell-nix/releases/tag/c-sta... It lost this ability temporarily when switching to Meson, but I fixed it in GTK3 and GTK4. But I just checked and apparently it is broken again: https://gitlab.gnome.org/GNOME/gtk/-/issues/3774#note_1097469 https://gitlab.gnome.org/GNOME/gtk/-/issues/3774#note_109746...
- PaulDavisThe1st 6y agoOh, that's right. There's some option to build all modules as static libs or include them in the main .a ... sorry, I forgot about that. Did GTK3 or GTK4 ever become relocatable on Linux?
- nh2 6y agoWell, looks like you just turned right: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3519#note_1099460 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3519#not...