babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.07k stars 183 forks source link

[Question] - Ulfius' linked libraries #224

Closed kiranjeet98 closed 2 years ago

kiranjeet98 commented 2 years ago

ulfius version used - 2.7.8

I am using ulfius for my rest interface. But i can see that apart from linking with the required libraries my binary is getting linked with additional libraries shown below:

    libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f142a1ce000)
    libidn.so.11 => /lib64/libidn.so.11 (0x00007f1429f9b000)
    libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f1429d6e000)
    libssl3.so => /lib64/libssl3.so (0x00007f1429b15000)
    libsmime3.so => /lib64/libsmime3.so (0x00007f14298ed000)
    libnss3.so => /lib64/libnss3.so (0x00007f14295be000)
    libnssutil3.so => /lib64/libnssutil3.so (0x00007f142938e000)
    libplds4.so => /lib64/libplds4.so (0x00007f142918a000)
    libplc4.so => /lib64/libplc4.so (0x00007f1428f85000)
    libnspr4.so => /lib64/libnspr4.so (0x00007f1428d47000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f1428afa000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f1428811000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f14285de000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f14283da000)
    liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007f14281cb000)
    libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007f1427f76000)
    libcap.so.2 => /lib64/libcap.so.2 (0x00007f1427d71000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f1427b69000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f1427942000)
    liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f142771c000)
    liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f1427507000)
    libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f1427286000)
    libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f1427081000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1426e68000)
    libdw.so.1 => /lib64/libdw.so.1 (0x00007f1426c17000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f1426a01000)
    libssl.so.10 => /lib64/libssl.so.10 (0x00007f142678f000)
    libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f142632c000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f142611c000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f1425f18000)
    libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007f1425cfb000)
    libattr.so.1 => /lib64/libattr.so.1 (0x00007f1425af6000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f1425894000)
    libelf.so.1 => /lib64/libelf.so.1 (0x00007f142567c000)
    libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f142546c000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f1425235000)
    libfreebl3.so => /lib64/libfreebl3.so (0x00007f1425032000)

Could you please explain what is the reason these libraries are getting linked?

babelouest commented 2 years ago

Hello @kiranjeet98 ,

As mentionned in the README.md file, Ulfius, with the default build, requires the following dependencies:

All those libraries are linked to other libraries as well, that's why the ldd output is that long.

The only required dependency is GNU Libmicrohttpd, you can build Ulfius without the other if you want, check the install documentation if you want to disable one or more dependecies.

kiranjeet98 commented 2 years ago

But i can see there is a difference in output of ldd command in different OS. I have checked in rocky linux and ubuntu. libidn.so.11 ,libssl3.so ,libsmime3.so,libnss3.so,libnssutil3.so ,libplds4.so , libplc4.so , libnspr4.so => are listed in ouput of ldd command in rocky linux OS but are not listed in ubuntu. What is the reason for this?

babelouest commented 2 years ago

It depends on the distribution's build process with the dependencies.

For example, libcurl is a library with a lot of dependencies, and some dependencies may be replaced by other ones, or skipped by the distribution, that's why you can have differences in ldd commands in different OS or distributions, or even different versions of the same distribution.

kiranjeet98 commented 2 years ago

okay Thanks.