Last night I spent many hours and encountered many issues when I tried to upgrade to Ubuntu 22.04. Nevertheless, after resolving all issues, my weechat-matrix plugin was broken again with many nondescript errors.

The toughest one, after upgrading to the latest version of libolm and it’s Python bindings, was a symbol error with occurred when trying to import the olm package into Python:

In [1]: import olm
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_13271/1498315781.py in <module>
----> 1 import olm

/usr/local/lib/python3.10/dist-packages/python_olm-3.2.12-py3.10-linux-x86_64.egg/olm/__init__.py
in <module>
     22 |  © Copyright 2018 by Damir Jelić
     23 """
---> 24 from .utility import ed25519_verify, OlmVerifyError, OlmHashError,
sha256
     25 from .account import Account, OlmAccountError
     26 from .session import (

/usr/local/lib/python3.10/dist-packages/python_olm-3.2.12-py3.10-linux-x86_64.egg/olm/utility.py
in <module>
     37 
     38 # pylint: disable=no-name-in-module
---> 39 from _libolm import ffi, lib  # type: ignore
     40 
     41 from ._compat import to_bytearray, to_bytes

ImportError: /usr/local/lib/python3.10/dist-packages/python_olm-3.2.12-py3.10-linux-x86_64.egg/_libolm.abi3.so: undefined symbol: _olm_error_to_string

OK, let’s check what’s going on here… What version of libolm is used by the module?

$ ldd /usr/local/lib/python3.10/dist-packages/python_olm-3.2.12-py3.10-linux-x86_64.egg/_libolm.abi3.so
	linux-vdso.so.1 (0x00007fffa8b21000)
	libolm.so.3 => /usr/local/lib/libolm.so.3 (0x00007f2284e7b000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2284c53000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2284a27000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2284ef7000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2284940000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2284920000)

This looks like it’s the one I just installed. Let’s check if the symbol is present.

alex@picobeast:~$ readelf -Ws /usr/local/lib/libolm.so.3 | grep olm_error_to_string
  155: 0000000000013260    30 FUNC    LOCAL  DEFAULT   14 _olm_error_to_string

WTF? Whyyyyyyyy…

Things I tried:

  1. Recompiling
  2. Cursing
  3. Reinstalling
  4. Yelling at my terminal
  5. Crying

Nevertheless. I could not find the root-cause at all, so I tried checking out the latest tagged-release instead of HEAD and that worked although it looks the same.

For historic purposes:

$ git clone https://gitlab.matrix.org/matrix-org/olm
$ cd olm
$ git checkout 3.2.12
$ cmake . -Bbuild
$ cmake --build build
$ sudo cmake --install build
$ cd python/
$ python3 setup.py build
$ sudo python3 setup.py install
$ echo 'import olm' | python3
$ echo $?
0

Crazy.