GTK4 and rest , build as a static library

Hello,

OK, GTK 4 released:

I want to use it together with some other libraries as a single or multiple static library.

What files should be in the project to build a static library ? Since there are .h files and .c files in several folders in GTK source code given at link above.

What about others like GLib Pango etc. Can one build all into a single static library or one has to build several static libraries , one for each project ?

When initializing meson (usually with meson _build/), you need to pass the -Ddefault_library=static so it’ll build libraries statically instead of shared libraries.

For now I am following the file README.md in GTK 4. OS is Ubuntu 20.04 . meson and ninja were available to install as packages. But newer versions were required for GTK. I downloaded source and built both of them. Now try is:

$ ‘/home/mehdi/.local/bin/meson’ _build

Output is:

Dependency glib-2.0 found: NO found 2.64.3 but need: ‘>= 2.66.0’

I tried to build glib 2.9 from source. Problem is glib 2.64 can not easily be removed. Many depending packages might be removed too. How can I tell meson to use the newer glib ?

Don’t do that, it’s a waste of your time.

I strongly recommend you use Flatpak, if you want to distribute your application alongside its dependencies.

GLib 2.9 is definitely not what you should build.

You should not be building GTK and its dependencies yourself, if you don’t already know how to deal with dependencies and build issues.

My recommendation for you is to install GNOME Builder from Flatpak, and then add the Nightly GNOME SDK, which contains GTK4 already.

3 Likes

Thanks for your recommendation. I may wait for distribution’s packages to be available. It seems I better be patient.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.