Undefined reference to `g_memdup2' when building from source


How would you go about what appears to be an outdated (or too new) version of libpangosft on Ubuntu, when building OpenCV from source?

[ 18%] Linking CXX executable ../../bin/opencv_test_core
/usr/bin/ld: /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0: undefined reference to `g_memdup2'
collect2: error: ld returned 1 exit status

Is there any build flag that makes the OpenCV build build its own libpangoft? Or can you recommend how to install an appropriate version of that library without it system-wide replacing the Ubuntu integrated existing one?

I’m buliding from source for the first time on Ubuntu 22.04.

I’m already using -DBUILD_TIFF=ON due to an earlier incompatibility to system installed libraries …