Statically linked binary for kcat or kafkacat

922 Views Asked by At

While trying to build kcat (Github edenhill/kcat - formerly known as kafkacat), I've stumbled upon some issues with library dependencies after the build has been successful, even though the build script has specific parameters for a static build. The use case is for building a binary that should theoretically work on multiple versions of the OS, where in my case is RHEL 7 & 8. Building kcat on either RHEL 7 or RHEL 8, will make the build dependent on the libraries (libcrypto.so.1.1 and libssl.so.1.1) from the version hosting the build:

(rhel7)# ldd kcat
./kcat: /lib64/libpthread.so.0: version `GLIBC_2.28' not found (required by ./kcat)
./kcat: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./kcat)
    linux-vdso.so.1 =>  (0x00007ffdb4dfc000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f0be4261000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f0be405d000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0be3e41000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f0be3c39000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f0be3a23000)
    libcrypto.so.1.1 => not found
    libssl.so.1.1 => not found
    libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007f0be3806000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f0be35ec000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f0be33b5000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f0be3168000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f0be2e7f000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f0be2c4c000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f0be2a48000)
    libcurl.so.4 => /lib64/libcurl.so.4 (0x00007f0be27de000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f0be2410000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f0be4563000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f0be2200000)
    libfreebl3.so => /lib64/libfreebl3.so (0x00007f0be1ffd000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f0be1df9000)
    libidn.so.11 => /lib64/libidn.so.11 (0x00007f0be1bc6000)
    libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f0be1999000)
    libssl3.so => /lib64/libssl3.so (0x00007f0be1740000)
    libsmime3.so => /lib64/libsmime3.so (0x00007f0be1518000)
    libnss3.so => /lib64/libnss3.so (0x00007f0be11e9000)
    libnssutil3.so => /lib64/libnssutil3.so (0x00007f0be0fb9000)
    libplds4.so => /lib64/libplds4.so (0x00007f0be0db5000)
    libplc4.so => /lib64/libplc4.so (0x00007f0be0bb0000)
    libnspr4.so => /lib64/libnspr4.so (0x00007f0be0972000)
    liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007f0be0763000)
    libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007f0be050e000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f0be02e7000)
    libssl.so.10 => /lib64/libssl.so.10 (0x00007f0be0075000)
    libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f0bdfc12000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f0bdf9b0000)

On the building host:

(rhel8)# ldd kcat
    linux-vdso.so.1 (0x00007ffd9096e000)
    libm.so.6 => /lib64/libm.so.6 (0x00007febf8734000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007febf8530000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007febf8310000)
    librt.so.1 => /lib64/librt.so.1 (0x00007febf8108000)
    libz.so.1 => /lib64/libz.so.1 (0x00007febf7ef1000)
    libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007febf7a08000)
    libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007febf7774000)
    libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007febf7556000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007febf733f000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007febf7116000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007febf6ec1000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007febf6bd8000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007febf69c1000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007febf67bd000)
    libcurl.so.4 => /lib64/libcurl.so.4 (0x00007febf652f000)
    libc.so.6 => /lib64/libc.so.6 (0x00007febf616a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007febf8ab6000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007febf5f59000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007febf5d55000)
    libnghttp2.so.14 => /lib64/libnghttp2.so.14 (0x00007febf5b2e000)
    libidn2.so.0 => /lib64/libidn2.so.0 (0x00007febf5910000)
    libssh.so.4 => /lib64/libssh.so.4 (0x00007febf56a1000)
    libpsl.so.5 => /lib64/libpsl.so.5 (0x00007febf5490000)
    libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007febf5242000)
    liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007febf5032000)
    libbrotlidec.so.1 => /lib64/libbrotlidec.so.1 (0x00007febf4e25000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007febf4bfb000)
    libunistring.so.2 => /lib64/libunistring.so.2 (0x00007febf487a000)
    libbrotlicommon.so.1 => /lib64/libbrotlicommon.so.1 (0x00007febf4659000)
    libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007febf43d5000)

The boostrap script seems to mark the following libraries as dynamic (most of them, if not all of them are installed from RHEL packages):

MKL_DYNAMIC_LIBS         -lavro -lm -ldl -lpthread -lrt -lz -lcrypto -lssl -lsasl2 -lm -ldl -lpthread -lrt -lpthread -lrt -lz -lcrypto -lz -ldl -lssl -lcrypto -lz -ldl -lsasl2 -ldl -lresolv -lcrypt -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl

Are there any tools, build or compile flags that might enforce building a statically linked binary (that of course, I can still use in my case)?

Thanks!

0

There are 0 best solutions below