Stuck building Gimp from source

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=...

Instead of compiling all the dependsies I would recommend to have a look at flatpack_buid.

even for a flatpak/appimage/snap … you are building all the dependencies. you just install them into a special container format instead of your system. both ways will work just fine.

But flatpack_buld does all the work for you. It creates the container, downloads all dependencies and compiles them. You just need the manifest.

I am not planning to build or download or whatever one needs to do to work with flatpak. I’m sure it’s the greatest thing since hotcakes were invented. But I don’t want to learn how to use flatpak.

OK, starting over this time on my Gentoo computer (so I don’t have to keep running upstairs to the other computer) :slight_smile: :

  • I already have dev-util/meson-0.46.1 installed from portage.

  • At the command line I established my prefix for building GIMP from git.

  • I cloned json-glib.

  • I cd’ed to the just-cloned json-glib source code folder.

Now what do I type next? Do I make a build folder inside the json-glib folder? If so, what do I call it?

this is a very small package where I added a meson build

https://build.opensuse.org/public/build/home:darix:playground/openSUSE_Tumbleweed/x86_64/mmproxy/_log

search for “export CC=clang”

Okay, I just cloned json-glib, cd-ed into it, made a directory called ‘_build’, and attempted to run the commands you listed. I got as far as ’

ERROR: Target 'Gir' can't be generated as 'g-ir-scanner' could not be found

That seems to be something in the GObject-Introspection dependency, which the README.md says is optional.

So, to sum it up:

git clone https://gitlab.gnome.org/GNOME/json-glib
cd json-lib
mkdir _build
meson _build .

…and that’s as far as I get. Gotta go, datenight with my best friend…

OK, thanks to some helpful replies over on the GIMP developers mailing list (Developers - how to build json-glib in a prefix when building gimp from git in a prefix?), I finally managed to build json-glib and install it in a prefix.

Here are sample commands in case anyone else ever needs to build json-glib using meson. This is for building on Gentoo to install in my GIMP-2.99 prefix - Gentoo portage version of json-glib is plenty current enough to build babl/GEGL/GIMP from git - this is just a test build to verify the process:

git clone https://gitlab.gnome.org/GNOME/json-glib
$PREFIX=PREFIX=$HOME/code-install/gimp299/install
cd json-glib
mkdir build
cd build
meson --prefix=$PREFIX ..
ninja install

The above commands did install json-glib in the indicated prefix.

If you need a specific version of json-glib, of course download and unpack the appropriate tarball. As @ggbutcher indicated, an easy way to find the current location of the latest tarballs - for any Linux library, not just for json-glib - is to search for how to build that library for Linux from Scratch.

Reading further about meson/ninja, I may have to try it for rawproc. Geesh, after a year I had finally figured out autotools…

Thing is, I’ve done this a couple of times now, most recently for cmake, and I’ve always come back to autotools for two reasons: 1) it does it all, and 2) it’s the predominant build system in the libraries upon which I depend, so my autotools files work ok with them. Even with autotools, there were times I almost reverted back to my hack Makefile, which is still in the source tree.

Well, I need some retirement projects…

Well, I think you’d be better off thinking about porting to qt. But I don’t really know enough about what that would involve to be saying such things.

Or else stick with what you are currently using. After getting the correct commands to type I installed json-glib using meson without any problems on Gentoo. But on OpenSUSE Tumbleweed, even with the correct commands I’ve encountered two problems:

  1. The version of meson shipping with Tumbleweed is 0.46 (get it? This stuff hasn’t even reach 1.0, which would presumably be the first “deemed stable” version of meson). But json-glib wants 0.48 on OpenSUSE, not sure why, I cloned from the same repository on the same day on both Gentoo and OpenSUSE. So my attempt to build json-glib failed on OpenSUSE at the meson --prefix=$PREFIX .. command, though it succeeded on Gentoo - @patdavid - why is the forum software turning my two dots into three dots?

  2. So I used the OpenSUSE software search to locate a repository that provides meson 0.48 and installed it and tried again. This time the build failed on the “ninja install” command with the error that somehow OpenSUSE has the wrong libselinux library.

Which I don’t even have selinux installed at all on Gentoo, so there is probably a way to tell meson to not use selinux on OpenSUSE when installing something in a prefix. But I don’t know how to pass such an option - if indeed such an option can be passed in such a gnome-centric software as meson or json-glib.

So my attempt to update my instructions for building GIMP from source has come to a dead end. It works on Gentoo, not on OpenSUSE Tumbleweed, and I simply do not want to invest any more time in this venture.

If someone really can supply the missing information in an immediately useable form (type exactly this, do exactly that), I’ll continue my efforts to update my how to build GIMP page. In the meantime, it’s just not worth it to me to continue beating my head against this particular brick wall.

Oh, that’s on the list, too. Probably part-and-parcel with a reorg of rawproc; I generally like the tool chain approach, but the UI and batch workflow bear improvement.

Building image applications from source is a complicated mess of library dependencies. Thing is, unless you (a programmer) want to write all that jpeg/png/raw/tiff/cms/lensfun stuff from scratch, you’re stuck being a build-mother of a bunch of unruly children… :smile:

Here’s a clue why Tumbleweed is still on meson 0.46:
https://bugs.gentoo.org/show_bug.cgi?id=666968

Nice phrase! I like that!

here is a thought … instead of building everything from git … only build the really needed things from git. :slight_smile: