Resolving Harfbuzz Version Conflict When Building GIMP on Linux Mint 21.3

I’m trying to build the latest version of GIMP on Linux Mint 21.3, but I’m running into a linking error due to a version conflict with Harfbuzz. The GIMP build process requires Harfbuzz 2.8.2 or later, but my system has Harfbuzz 2.7.4 installed.

The linker is reporting an undefined reference to hb_blob_create_from_file_or_fail when building GIMP, which suggests that it’s still using the older Harfbuzz library from /usr/lib/x86_64-linux-gnu.

I’ve tried the following steps to resolve the issue:

  1. Updated my OS and Harfbuzz to the latest version package version
sudo apt-get install libharfbuzz0b
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libharfbuzz0b is already the newest version (2.7.4-1ubuntu3.1).
0 to upgrade, 0 to newly install, 0 to remove and 5 not to upgrade.
  1. Built the latest version of Harfbuzz (6.0.0) from source and installed it to /usr/local/lib.

  2. Added the following lines to my build script to update the LD_LIBRARY_PATH environment variable:

export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib"

With these last two steps, GIMP partially builds and successfully finds the Harfbuzz dependency:

Dependency harfbuzz found: YES 6.0.0 (cached)

Then fails:

lbacktrace
/usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so
/usr/lib/x86_64-linux-gnu/libpango-1.0.so
/usr/lib/x86_64-linux-gnu/libharfbuzz.so
/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so
/usr/lib/x86_64-linux-gnu/libfontconfig.so
/usr/lib/x86_64-linux-gnu/libfreetype.so
/usr/lib/x86_64-linux-gnu/libmypaint.so
-fopenmp
/usr/lib/x86_64-linux-gnu/libjson-c.so
/usr/lib/x86_64-linux-gnu/libappstream-glib.so
-lm
-ldl
/usr/lib/x86_64-linux-gnu/libarchive.so
-fopenmp
/usr/local/lib/libharfbuzz.so
/usr/lib/x86_64-linux-gnu/libz.so
-Wl,--end-group
-fopenmp

/usr/bin/ld: app/text/libapptext.a.p/gimpfontfactory.c.o: in function gimp_font_factory_load_async_callback': gimpfontfactory.c:(.text+0x12ec): undefined reference to hb_blob_create_from_file_or_fail'
collect2: error: ld returned 1 exit status

The GIMP development team advised me to “fix my environment variables,” obviously, I’m unsure what specific changes are needed.

System details:

NAME="Linux Mint"
VERSION="21.3 (Virginia)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.3"
UBUNTU_CODENAME=jammy

Harfbuzz versions installed:
2.7.4 (system package)
6.0.0 (built from source and installed to /usr/local/lib)

What I’ve tried:

  • Getting the latest Package for the system.

  • Building Harfbuzz 6.0.0 from source and installing it to /usr/local/lib.

  • Updating the LD_LIBRARY_PATH environment variable in my build script.

  • Successfully linking to the latest Harfbuzz.

It looks like the linker is still trying to use the system HarfBuzz library from /usr/lib/x86_64-linux-gnu/libharfbuzz.so, which is causing the undefined reference to hb_blob_create_from_file_or_fail.

Question:

How can I ensure that the linker uses the Harfbuzz 6.0.0 library from /usr/local/lib instead of the system library from /usr/lib/x86_64-linux-gnu?

Build envs script:

# added for the latest self-built harfbuzz
export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib"

# before this error
export GIMP_PREFIX="${HOME}/Code/gimp-source"
export PATH="${GIMP_PREFIX}/bin:/usr/local/bin:$PATH"
export PKG_CONFIG_PATH="${GIMP_PREFIX}/share/pkgconfig:${GIMP_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export PKG_CONFIG_PATH="${GIMP_PREFIX}/lib64/pkgconfig:$PKG_CONFIG_PATH"
export XDG_DATA_DIRS="${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}${GIMP_PREFIX}/share:/usr/local/share:/usr/share"
export LD_LIBRARY_PATH="${GIMP_PREFIX}/lib:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export ACLOCAL_FLAGS="-I $INSTALL_PREFIX/share/aclocal $ACLOCAL_FLAGS"
GI_TYPELIB_PATH="${GIMP_PREFIX}/lib/girepository-1.0:${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"

arch="$(dpkg-architecture -qDEB_HOST_MULTIARCH 2> /dev/null)"
export PKG_CONFIG_PATH="${GIMP_PREFIX}/lib/${arch}/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="${GIMP_PREFIX}/lib/${arch}:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export GI_TYPELIB_PATH="${GIMP_PREFIX}/lib/${arch}/girepository-1.0:${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"

Build script:

#!/usr/bin/env bash

# $1 "nobuild" "compile" or "build"
# $2 "debug" or "release"
# $3 "gimp" or "imp" or "artbox"

build_compile="$1"
build_type="$2"
build_version="$3"
build_folder="$3"
build="false"
script_dir="$(dirname "$(realpath "$0")")"

# export build variables
source "$script_dir/definitions.sh" "$build_version"

# imp build variables? hack to swap build folder back to "gimp" in imp-source
if [ $build_version == "imp" ]; then
  build_folder="gimp"
fi

# build
if [ $build_compile == "build" ]; then
  echo $GIMP_PREFIX/build/$build_folder
  cd $GIMP_PREFIX/build/$build_folder
  echo "current directory: $(pwd)"
  git submodule update

  meson _build \
      --reconfigure \
      --prefix=${GIMP_PREFIX} \
      --buildtype=$build_type \
      -D python=enabled
  cd _build
  build="true"
fi

# compile
if [ $build_compile == "compile" ]; then
  echo $GIMP_PREFIX/build/$build_folder
  cd $GIMP_PREFIX/build/$build_folder
  echo "current directory: $(pwd)"
  git submodule update

  cd $GIMP_PREFIX/build/$build_folder
  cd $GIMP_PREFIX/build/$build_folder/_build
  build="true"
fi

if [ $build == "true" ]; then
  ninja && ninja install
  if [ $? -ne 0 ]; then
    echo "\nError: $build_compile $build_version FAILED\n"
  fi
  echo -e "\n $build_compile $build_version SUCCESS\n"
fi

read -n 1 -r -s -p "Press any key to launch $build_version..."

source $script_dir/launch-active.sh $build_type $build_version

Not too useful comment of mine: this remembers me what is advised in the developer site:

As a general advice, software contributors should anyway use distributions providing reasonably recent packages (e.g. Debian testing, Fedora, Arch) if you don’t want to have to compile yourself too many dependencies, which sadly is the case of distributions with longer support (e.g. Ubuntu LTS).

Although the Meson build process used by GIMP is aware of the latest version of Harfbuzz, there is no way to adjust the GIMP build process so that it does not try and link to older versions of Harfbuzz that the system uses? And you are suggesting that I switch distributions from Linux Mint to Debian Testing to resolve this issue with my environment variables?"

switch distributions from Linux Mint to Debian Testing to resolve this issue with my environment variables?"

Not necessarily. Linux Mint 22 have a quite recent version of that dependency, but some other dependency can become outdated in the future, since it is based on Ubuntu 24.04 (a LTS distro afterall).

I recommended doing a full read on the Linux building page since it was updated with many details to make possible a informed decision: GIMP Developer - Building GIMP for Linux

I’ve looked at the linked page, but unfortunately, I couldn’t find a solution that would directly resolve the Harfbuzz version conflict when building GIMP on Linux Mint 21.3.

I’ve drawn a few conclusions:

  • The compiler’s behavior of linking to older library versions instead of the latest available might be specific to my system configuration.
  • Modifying environment variables is not a well-defined solution and may introduce unknown variables.
  • Users who attempt to build the upcoming stable release of GIMP v3 on a stable Linux distribution like Linux Mint may encounter a similar issue.

For now, I’m content to stick with a stable version of Linux and wait for the Harfbuzz version to be updated. Alternatively, it might be worth exploring adjustments to the GIMP build system to ensure it uses the latest compiled libraries.

In the meantime, I found that reverting the change that caused the problem was a relatively quick and straightforward solution.

That’s a wrong statement. Linux Mint 21.3 is actually not stable but old stable and that classification have implications on building things.

GIMP 3 stable can be built on every Debian based distro after Debian stable/Bookworm/12. Linux Mint 22 fulfills this requirement (since it is based on Ubuntu 24.04), 21 series not (which is pre-Bookworm).

This is interesting, and getting somewhere practical for me. I asked on the Linux Mint forums which version of Harfbuzz is packaged with version 22 a few days ago. No response as yet, this would be good to know.

Linux Mint 22 (aka ‘wilma’) is based on Ubuntu 24.04, so if the package you are looking for is not in the Mint-specific packages for their 22/wilma release, you’d search for it in Ubuntu’s packages for the noble/24.04 release.

https://packages.ubuntu.com/search?keywords=harfbuzz&searchon=names&suite=noble&section=all

I had looked at this site before and wondered if it was using version 8, which confused me because when I built it from source, it was version 6.0. So I lost confidence in the numbering. I’ll look into moving onto 22.

What site exactly are you referring to, and what did you install or build from source?

Please provide links to specific sites and/or packages in your answer, if you recall these.

The same site you mentioned:

https://packages.ubuntu.com/search?keywords=harfbuzz&searchon=names&suite=noble&section=all

And to correct my comment, I lost confidence in my understanding of the numbering system, not the numbering system itself. Please appreciate that these sites are complex to understand if you have never had to interpret them before, or know little beyond the surface appearance of Linux.

It looks like I somehow installed a build package for Harfbuzz that is version 6.0, which is not the latest version. I shall try upgrading to version 8 via Linux Mint 22.

Please don’t try moving to Linux Mint 22 from 21.3 because of the above commentary, it’s turned out right badly.

Do you think this is due to something being wrong with Linux Mint 22 itself, or could this be due to something you did (or did not) while upgrading?

As you know, it’s a complex situation and knowing the cause of the issue is not straightforward. A black screen after upgrading to Linux Mint 22 has been reported.

Upgrading is presented as a simple process. And it was until the black screen. Using Timeshift to restore from the tty was not possible after the upgrade, I reinstalled 21.3.

Moving back to 21.3 and trying to system restore using Timeshift, from before the upgrade, also caused a black screen. Recovery was then not possible with my skill set. Next stop was Debian Testing, which I set up and got working yesterday. Today I am going to switch to Debian Stable, to see if that is better for handling HDPI issues. An educational experience!

Hi Bruno,

I read through the build guide again and found the advice to look at the .yml file very helpful. It didn’t solve my original issue but made a fresh install simpler, thanks for updating the environment variables and install doc. The process went well on Debian Stable.

FYI, do get a few warnings that are a mystery to me, maybe you know the solution:

Host machine cpu: x86_64
../meson.build:97: WARNING: Module SIMD has no backwards or forwards compatibility and might not exist in future releases.
Library backtrace found: YES
../meson.build:582: WARNING: libbacktrace was found, but the test compilation failed.
Found CMake: /usr/bin/cmake (3.25.1)
WARNING: CMake Toolchain: Failed to determine CMake compilers state

the env variables I use:

# Assuming that you have toolchain installed
# If this don't work, so manually set the dirs
arch=$(cc -print-multiarch)

LIB_DIR=$(cc -print-multi-os-directory | sed 's/\.\.\///g')
arch | grep . && LIB_SUBDIR=$(echo arch'/')

# Universal variables (works in all POSIX OSes and archs)
export PATH="$GIMP_PREFIX/bin:$PATH"
gcc -print-multi-os-directory 2>/dev/null | grep ./ && LIB_DIR=$(gcc -print-multi-os-directory | sed 's/\.\.\///g') || LIB_DIR="lib"
gcc -print-multiarch 2>/dev/null | grep . && LIB_SUBDIR=$(echo $(gcc -print-multiarch)'/')
export PKG_CONFIG_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export XDG_DATA_DIRS="${GIMP_PREFIX}/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
export GI_TYPELIB_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}girepository-1.0${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"

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