0

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

[ 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

I have followed from the official OpenCV build guide both with and without opencv_contrib, while also using -DBUILD_TIFF=ON due to an earlier incompatibility to system installed libraries.

This is with Ubuntu 22.04.

$ apt list libglib2.0-*
libglib2.0-dev-bin/jammy-updates,jammy-security,now 2.72.4-0ubuntu2.3 amd64 [installed,automatic]
libglib2.0-dev-bin/jammy-updates,jammy-security 2.72.4-0ubuntu2.3 i386
libglib2.0-dev/jammy-updates,jammy-security,now 2.72.4-0ubuntu2.3 amd64 [installed]
libglib2.0-dev/jammy-updates,jammy-security 2.72.4-0ubuntu2.3 i386
libglib2.0-doc/jammy-updates,jammy-updates,jammy-security,jammy-security 2.72.4-0ubuntu2.3 all
libglib2.0-tests/jammy-updates,jammy-security 2.72.4-0ubuntu2.3 amd64
libglib2.0-tests/jammy-updates,jammy-security 2.72.4-0ubuntu2.3 i386

libglib2.0-dev is already the newest version (2.72.4-0ubuntu2.3).

$ ldd /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
    linux-vdso.so.1 (0x00007ffc91dd9000)
    libpango-1.0.so.0 => /lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f99f8f43000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f99f8e09000)
    libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f99f8da9000)
    libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f99f8bcf000)
    libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f99f8b00000)
    libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f99f8ab4000)
    libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f99f89ec000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f99f87c3000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f99f86dc000)
    libfribidi.so.0 => /lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007f99f86c0000)
    libthai.so.0 => /lib/x86_64-linux-gnu/libthai.so.0 (0x00007f99f86b5000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f99f863d000)
    libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007f99f8630000)
    libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f99f8629000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f99f860d000)
    libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f99f85c9000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f99f859d000)
    libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f99f8574000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f99f8543000)
    libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f99f853a000)
    libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f99f84ff000)
    libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f99f84f1000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f99f8fea000)
    libdatrie.so.1 => /lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f99f84e6000)
    libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f99f84af000)
    libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f99f8418000)
    libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f99f83f5000)
$ cmake --build . --verbose
[ 16%] Linking CXX executable ../../bin/opencv_test_core
cd opencv/build/modules/core && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_test_core.dir/link.txt --verbose=1
/usr/bin/c++    -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined CMakeFiles/opencv_test_core.dir/test/ocl/test_arithm.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_channels.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_dft.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_gemm.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_image2d.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_matrix_expr.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_matrix_operation.cpp.o CMakeFiles/opencv_test_core.dir/test/ocl/test_opencl.cpp.o CMakeFiles/opencv_test_core.dir/test/test_arithm.cpp.o CMakeFiles/opencv_test_core.dir/test/test_async.cpp.o CMakeFiles/opencv_test_core.dir/test/test_concatenation.cpp.o CMakeFiles/opencv_test_core.dir/test/test_conjugate_gradient.cpp.o CMakeFiles/opencv_test_core.dir/test/test_countnonzero.cpp.o CMakeFiles/opencv_test_core.dir/test/test_cuda.cpp.o CMakeFiles/opencv_test_core.dir/test/test_downhill_simplex.cpp.o CMakeFiles/opencv_test_core.dir/test/test_ds.cpp.o CMakeFiles/opencv_test_core.dir/test/test_dxt.cpp.o CMakeFiles/opencv_test_core.dir/test/test_eigen.cpp.o CMakeFiles/opencv_test_core.dir/test/test_hal_core.cpp.o CMakeFiles/opencv_test_core.dir/test/test_hasnonzero.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin_emulator.cpp.o CMakeFiles/opencv_test_core.dir/test/test_io.cpp.o CMakeFiles/opencv_test_core.dir/test/test_logtagconfigparser.cpp.o CMakeFiles/opencv_test_core.dir/test/test_logtagmanager.cpp.o CMakeFiles/opencv_test_core.dir/test/test_lpsolver.cpp.o CMakeFiles/opencv_test_core.dir/test/test_main.cpp.o CMakeFiles/opencv_test_core.dir/test/test_mat.cpp.o CMakeFiles/opencv_test_core.dir/test/test_math.cpp.o CMakeFiles/opencv_test_core.dir/test/test_misc.cpp.o CMakeFiles/opencv_test_core.dir/test/test_opencl.cpp.o CMakeFiles/opencv_test_core.dir/test/test_operations.cpp.o CMakeFiles/opencv_test_core.dir/test/test_ptr.cpp.o CMakeFiles/opencv_test_core.dir/test/test_quaternion.cpp.o CMakeFiles/opencv_test_core.dir/test/test_rand.cpp.o CMakeFiles/opencv_test_core.dir/test/test_rotatedrect.cpp.o CMakeFiles/opencv_test_core.dir/test/test_umat.cpp.o CMakeFiles/opencv_test_core.dir/test/test_utils.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.sse2.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.sse3.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.ssse3.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.sse4_1.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.sse4_2.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.fp16.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.avx.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.avx2.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin256.avx2.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin128.avx512_skx.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin256.avx512_skx.cpp.o CMakeFiles/opencv_test_core.dir/test/test_intrin512.avx512_skx.cpp.o -o ../../bin/opencv_test_core  -Wl,-rpath,opencv/build/lib:anaconda3/lib ../../lib/libopencv_ts.a ../../lib/libopencv_highgui.so.4.10.0 -ldl -lm -lpthread -lrt ../../3rdparty/lib/libippiw.a ../../3rdparty/ippicv/ippicv_lnx/icv/lib/intel64/libippicv.a ../../lib/libopencv_videoio.so.4.10.0 ../../lib/libopencv_imgcodecs.so.4.10.0 ../../lib/libopencv_imgproc.so.4.10.0 ../../lib/libopencv_core.so.4.10.0 -lm -lpthread -lrt -Wl,-rpath-link,anaconda3/lib
7
  • 1
    Have you installed libglib2.0-dev? Commented Jun 6, 2024 at 16:46
  • 2
    Can you try ldd /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 and check which library is "not found"? Commented Jun 11, 2024 at 11:15
  • 2
    Also, try cmake --build . --verbose so you can see the exact build command that failed. (found at stackoverflow.com/a/63690389) Commented Jun 11, 2024 at 12:17
  • 2
    I have the same versions of the mentioned libraries and it compiled clean for me. What exact version of opencv are you building? Commented Jun 11, 2024 at 21:55
  • 1
    Include the output from apt list libglib2.0-* in your question please. Commented Jun 12, 2024 at 18:03

2 Answers 2

0

It is a GLib error, as this function should be presented from any version of GLib since 2.68. Maybe, it is necessary to update the libpango-dev installation. Also, I suppose, there could be a linking issue when the test executable opencv_test_core is not declared explicitly linked to GTK library set due to some unhandled case in the build scenario. This could be fixed using something like this trick.

Sign up to request clarification or add additional context in comments.

2 Comments

As a case in point for similar cases, how do we trace back from the original error message, that it is a GLib error?
g_memdup2 is a Glib function
0

Just for the record, in my specific case after uninstalling Anaconda it builds as is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.