How to compile GTK and all its dependencies statically using my toolchain with glibc-2.29

I am trying to compile GTK and all its dependencies statically using my custom toolchain, which is based on glibc-2.29. The toolchain was built using crosstool-ng and targets x86_64-unknown-linux-gnu.

What I Have:

  • A working toolchain with static libraries (libc.a, libm.a, libstdc++.a, etc.).
  • LLVM/Clang toolchain for building software.
  • GTK source and its dependencies (glib, pango, cairo, gdk-pixbuf, etc.).

What I Need Help With:

  1. Dependency Handling:
  • What is the best way to build and link all GTK dependencies statically?
  • Are there any known issues when statically compiling dependencies like glib or pango?
  1. Build Configuration:
  • What meson or autotools options should I use to enforce static linking?
  • Are there any flags required for pkg-config to locate static libraries?
  1. Toolchain Compatibility:
  • Do I need to patch any dependency to ensure compatibility with glibc-2.29?
  • Has anyone successfully built a fully static GTK binary with a similar setup?

Any guidance, experience, or recommended steps would be greatly appreciated. Thanks!

Static builds of GTK are not supported. We don’t intentionally break things, but we also don’t guarantee that any change won’t break them.

Use GTK as Meson subproject in your own build.

GLib is generally tested for static builds, but it’s the exception.

You should read the documentation of Meson and pkg-config.

The version of the GNU libc is immaterial to static builds of the GTK stack.

1 Like