Stuck building Gimp from source

Glenn, you are in the fast lane, I’m looking for the sign to the Motorway!

Yeah, I probably wasn’t clear. Ubuntu LTS 18.04 might work better…

I used to be able to build GIMP GIT using a modified version of Elles script. It worked nicely, but now I am using Xubuntu 18.04 so I am trying to build GIMP from source code on this OS.

I’m trying to update my “Building GIMP for artists and photographers” article ()Building GIMP for artists and photographers). I’m testing the build process on a computer running OpenSUSE. I’m currently stuck on building json-glib, which uses “meson”.

I don’t know what meson is, and I don’t really want to know what meson is :slight_smile: . But I’m hoping some kind soul can tell me what the commands are to build json-glib from source using meson.

Presumably also I’ll need to install some program or another that probably has the word “meson” in its name, so that would also be a nice thing to know.

Any help is very greatly appreciated. Otherwise I’ll just take the “how to build” article down and put an apology in its place.

http://mesonbuild.com/

hi Elle. Gimp! As you might see above, I was going to try Gimp under Sabayon. I still am, but just haven’t got round to it.

I just had a quick look at your query. This is the blind leading the whatever! However, Meson seems to be a project building compiler system - see http://mesonbuild.com/

And towards the bottom of this page, you can see it being used to build Shotwell. https://wiki.gnome.org/Apps/Shotwell/BuildingAndInstalling

This all seems very messy and a heavy learning curve to build just one dependency for Gimp! I hope Morgan’s sabayon command still works when I eventually get round to refreshing my current (old-ish) Gimp which is under Ubuntu. Can’t the Gimp devs you know explain how to build Gimp?!

Best wishes, Andrew

@afre - thanks! for the link to the meson home page. But at this point I don’t want to figure out the commands for myself. I want someone to say “cd to the json-glib source folder and type these exact commands”.

As @RawConvert notes, trying to learn the meson build system just to build one stupid little dependency for GIMP, well, that’s a steep hill to climb. So if some kind soul who already knows the answer doesn’t share the precise, specific commands to type into the terminal, I’m just letting the whole thing drop. I just do not want to make the effort to learn another build system. I’ve tried very hard to spare other people this sort of hill to climb when building GIMP, and I find I don’t want to climb this sort of hill again.

@RawConvert - that’s a good idea, asking the other GIMP devs. I’ll go ask on #GIMP IRC and see if anyone knows the exact commands to type.

I’m on my phone, so I can’t confirm this, but the Linux From Scratch instructions for json-glib look like they use a regular autotools build system. It may be they’re moving to meson, but take a look in the json-glib directory for configure - if it’s still there, try the LFS instructions.

Geesh, another build system to figure out…

No “configure”, no “autogen.sh”. There’s a readme but the instructions are rather general, not sure how to tell it to build in the prefix rather than for the entire OS.

OK, on IRC a very kind person gave these commands:

meson _build .   
ninja -C _build 
meson test -C _build  
sudo ninja -C _build install

But these commands are obviously for installing somewhere besides in a specific prefix. Unless meson just magically knows what prefix the person typing the commands has in mind?

For glib, which uses make, one types this to establish the prefix (assuming the prefix really is $HOME/code/gimpdefault/install) and build glib:

PREFIX=$HOME/code/gimpdefault/install
./autogen.sh --prefix=$PREFIX

My question is how to establish the prefix for json-glib using meson. And of course what software to install to use meson at all.

And that is why I rely on others’ builds. At one point, I tried building everything. However, as time went by, I grew tired of bending over backwards.

PS I provided the link not for you per se but for our lovely readers.

OK, apparently the way to establish the prefix is this (many thanks to the kind person on IRC for helping with this!):

meson configure -Dprefix=$HOME/code/gimpdefault/install

So I’ll go upstairs to the other computer and see if I can get json-glib to build.

Meson is used in a lot of the new GTK stuff, and Elementary OS is also using meson. I assume their IRC or other support channels are great places to get more info.

Meson is natively supported in flatpak, so in the flatpak manifest, one simply says build: meson and then flatpak builder takes care of it.

Well, that was a great big fail. I typed in the meson configure command and got this:

bash: meson: command not found

So I installed a package called “meson” and tried again, and got this:

Meson configurator encountered an error:
ERORR: Directory /home/elle/code/gimpdefault/build/json-glib 
does not seem to be a Meson build directory

So unless/until someone can explain how to get past this brick wall, I guess this is where I’ll stop. In the meantime I’ll go post an apology on my “how to build GIMP” page.

I loathe the new GTK stuff. So very much loathe all of it.

I think a coworker is building gimp snapshots with https://build.opensuse.org/ even together with the gimp team. I have to poke him about the status of that project.

My own goal wasn’t to build GIMP from source specifically on OpenSUSE. I don’t actually even run OpenSUSE on my main computer (I run Gentoo). I was just trying to update my “how to build” instructions (for any version of Linux) by running through all the steps using OpenSUSE.

I have up-to-date Tumbleweed on the upstairs computer, and so likely I don’t even need to build json-glib at all for that computer. But some people will need to install json-glib from source on their computers, if they want to install GIMP from source. So it would be nice to know the exact commands to type, not just for OpenSUSE, but in general.

Is Meson another one of those Fedora/GNOME softwares? Wikipedia (Meson (software) - Wikipedia) says this:

GNOME has made it a goal to port its projects to Meson.[14] As of late 2017, GNOME Shell itself exclusively requires Meson after abandoning Autotools,[15] and central components like GTK+, Clutter-GTK, GLib and GStreamer can be built with Meson.[14]

Systemd relies on Meson since dropping Autotools in version 234.[16]

Efforts are made to port Xorg[17] and Mesa[18] to Meson.

Bleh.

yes. you wont get around meson anymore. Writing meson files is a bit less work than autotools stuff.

OK, if meson is something that one can’t avoid in the future, at least for gtk software, it would be nice if those people trying to build software from source would have some nice easy-to-follow examples.

I cloned jason-glib using this command:

git clone https://gitlab.gnome.org/GNOME/json-glib

Then I tried to build json-glib using these commands:

meson configure -Dprefix=$HOME/code/gimpdefault/install
meson _build .
ninja -C _build
meson test -C _build
ninja -C _build install

But I never got past the first command because meson decided I actually wasn’t in a meson build folder.

What are the specific commands for actually building json-glib using meson, and having it install in the indicated prefix? What did I do wrong?

From the meson quickstart:

“The only thing to note is that you need to create a separate build directory. Meson will not allow you to build source code inside your source tree. All build artifacts are stored in the build directory. This allows you to have multiple build trees with different configurations at the same time. This way generated files are not added into revision control by accident.”

autotools lets you build right in the root directory. If you’re using a git clone, or need to build for multiple architectures, this can vex you.

in json-glib, mkdir build, cd build, and try from there…

our opensuse %meson macro does:

    export LANG=C.UTF-8                      
    export CFLAGS="${CFLAGS:--fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g}"     
    export CXXFLAGS="${CXXFLAGS:--fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g}" 
    export FFLAGS="${FFLAGS:--fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g}"     
    export FCFLAGS="${FCFLAGS:--fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g}"   
    /usr/bin/meson                              \
        --buildtype=plain                   \
        --prefix=/usr                 \
        --libdir=/usr/lib64                 \
        --libexecdir=/usr/lib         \
        --bindir=/usr/bin                 \
        --sbindir=/usr/sbin               \
        --includedir=/usr/include         \
        --datadir=/usr/share               \
        --mandir=/usr/share/man                 \
        --infodir=/usr/share/info               \
        --localedir=/usr/share/locale      \
        --sysconfdir=/etc         \
        --localstatedir=/var   \
        --sharedstatedir=/var/lib \
        --wrap-mode=nodownload    \
        . build \

so @Elle was actually correct just instead of the -Dprefix=... you need --prefix=...