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:
- 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.
-
Built the latest version of Harfbuzz (6.0.0) from source and installed it to
/usr/local/lib
. -
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