Libevent-2.1.so.6 not found, but 2.1.7 installed

I get an error when running a test in my application.

I’m on Ubuntu 20.04 using Crystal v 1.7.3 and I have libevent-2.1.so.7 in my /usr/lib directory.

Why is crystal looking for 2.1.6 only and can I change that or should I install the 2.1.6 libs as well?

I installed my crystal binary through these instructions Install On Ubuntu - The Crystal Programming Language

My program for some reason insists on 2.1.6 existing

ldd bin/mysqldumpsplitter
        linux-vdso.so.1 (0x00007ffe9ab1f000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f161b9da000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f161b967000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f161b944000)
        libevent-2.1.so.6 => not found
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f161b93a000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f161b934000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f161b917000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f161b725000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f161bedc000)

This is whats installed on my system

ldconfig -p | grep event
        libtevent.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libtevent.so.0
        libtevent-util.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libtevent-util.so.0
        libevent_pthreads-2.1.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libevent_pthreads-2.1.so.7
        libevent_openssl-2.1.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libevent_openssl-2.1.so.7
        libevent_extra-2.1.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libevent_extra-2.1.so.7
        libevent_core-2.1.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libevent_core-2.1.so.7
        libevent-2.1.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libevent-2.1.so.7

Crystal uses the system linker to link the executable. It just passes -levent and the linker takes care of choosing the version.
So this looks like some kind of misconfiguration in your system.

You can pass --cross-compile to the compiler. This generates an object file and prints a linker command. You need to run this command to link the executable. This could be helpful for debugging your linker setup as you don’t need to run the Crystal build step every time you try the linker.

1 Like

So I made a mistake. I copied my codebase from an old machine and didn’t realise I was actually executing the dynamically linked binary.

1 Like