Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need complete statically linked binary #3307

Open
2 tasks
sanketRmeshram opened this issue Feb 18, 2025 · 2 comments
Open
2 tasks

Need complete statically linked binary #3307

sanketRmeshram opened this issue Feb 18, 2025 · 2 comments
Labels
feature-request A feature should be added or improved.

Comments

@sanketRmeshram
Copy link

Describe the feature

We built the aws static libraries .
But this has lots of dynamic dependencies :

tech@code:~/sanket/aws/aws_standalone$ g++ aws_code.cpp -O3 -DNDEBUG -I /home/tech/sanket/aws/static/aws-sdk-cpp/install/include/  -L /home/tech/sanket/aws/static/aws-sdk-cpp/install/lib/ -laws-cpp-sdk-s3 -laws-cpp-sdk-s3-crt -laws-cpp-sdk-core -laws-crt-cpp -laws-c-mqtt -laws-c-event-stream -laws-c-s3 -laws-c-auth -laws-c-http -laws-c-io -ls2n -laws-c-compression -laws-c-cal -laws-c-sdkutils -laws-checksums -laws-c-common -ldl -lz -lpthread -lcurl -lcrypto
tech@code:~/sanket/aws/aws_standalone$ ldd a.out
        linux-vdso.so.1 (0x00007ffe56013000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007effc609e000)
        libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007effc5ff7000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007effc5400000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007effc5000000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007effc5919000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007effc5fd1000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007effc4c00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007effc60c7000)
        libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007effc5fa7000)
        libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007effc58f8000)
        librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007effc58d9000)
        libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007effc586c000)
        libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007effc5f91000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007effc535c000)
        libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007effc5308000)
        libldap-2.5.so.0 => /lib/x86_64-linux-gnu/libldap-2.5.so.0 (0x00007effc52a9000)
        liblber-2.5.so.0 => /lib/x86_64-linux-gnu/liblber-2.5.so.0 (0x00007effc585b000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007effc4f31000)
        libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007effc584d000)
        libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007effc4a56000)
        libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007effc486b000)
        libhogweed.so.6 => /lib/x86_64-linux-gnu/libhogweed.so.6 (0x00007effc4ee9000)
        libnettle.so.8 => /lib/x86_64-linux-gnu/libnettle.so.8 (0x00007effc4ea3000)
        libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007effc47e9000)
        libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007effc471e000)
        libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007effc527a000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007effc5845000)
        libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007effc4e95000)
        libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007effc4e7a000)
        libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007effc4e57000)
        libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007effc45e3000)
        libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007effc4e3f000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007effc5271000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007effc4e2b000)
        libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007effc45d6000)
tech@code:~/sanket/aws/aws_standalone$

We want to link all those dependencies statically, so we tried using the -static flag . Getting this error when tried with -static flag :
https://pastebin.com/Z0Gr14q5

Then we tried using https://github.com/stunnel/static-curl to build the static curl library. But ran into many linking issues : https://pastebin.com/P0KZSgik

Use Case

We want a complete statically linked binary for our use case.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@sanketRmeshram sanketRmeshram added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 18, 2025
@SergeyRyabinin
Copy link
Contributor

Hi,

Thank you for submitting this issue.
We use cmake as a tool to build the SDK and we recommend to use cmake for consuming build and installed SDK by your application.
There is a config BUILD_SHARED_LIBS that instructs cmake to configure the SDK build.
There is also CMAKE_PREFIX_PATH that can be used to specify dependency libs location.

why to load the numa dynamically ?

This is AWS-CRT library package, according to the comment in the file

/* NUMA is funky and we can't rely on libnuma.so being available. We also don't want to take a hard dependency on it,

  • try and load it if we can. */

we can't rely on it being available, so a dynamic dispatch has been implemented.

We will follow up with the CRT libraries if it is something that could be refactored.

Best regards,
Sergey

@SergeyRyabinin SergeyRyabinin removed the needs-triage This issue or PR still needs to be triaged. label Mar 3, 2025
@sanketRmeshram
Copy link
Author

sanketRmeshram commented Mar 6, 2025

Hi @SergeyRyabinin ,
We tried using https://github.com/stunnel/static-curl to build the static curl library.
And gave path in CMAKE_PREFIX_PATH , So that it will use the static library .

Cmake command :

cmake ..  -DCMAKE_INSTALL_PREFIX=/home/tech/sanket/aws/static/aws-sdk-cpp/install -DBUILD_SHARED_LIBS=OFF -DBUILD_ONLY="s3-crt;s3" -DCMAKE_BUILD_TYPE=RelWithDebInfo  -DSIMPLE_INSTALL=ON -DCPP_STANDARD=17 -DCMAKE_PREFIX_PATH=/home/tech/sanket/curl-static-libs

But ran into following issue while building the aws library :
https://pastebin.com/YzV7vpsS

Static-Libs folder :

tech@code:~/sanket/curl-static-libs$ ll
total 24460
drwxr-xr-x 5 tech tech    4096 Mar  6 09:00 ./
drwxrwxr-x 7 tech tech    4096 Feb 27 13:43 ../
drwxr-xr-x 3 tech tech    4096 Feb 18 16:53 cmake/
-rw-r--r-- 1 tech tech  137504 Feb 18 16:53 libbrotlicommon.a
-rw-r--r-- 1 tech tech   58112 Feb 18 16:53 libbrotlidec.a
-rw-r--r-- 1 tech tech  854694 Feb 18 16:53 libbrotlienc.a
-rw-r--r-- 1 tech tech 2251412 Feb 18 16:53 libcares.a
-rwxr-xr-x 1 tech tech     945 Feb 18 16:53 libcares.la*
-rw-rw-r-- 1 tech tech 5592582 Mar  6 08:59 libcrypto.a
-rw-r--r-- 1 tech tech 1768912 Feb 18 16:53 libcurl.a
-rwxr-xr-x 1 tech tech    1349 Feb 18 16:53 libcurl.la*
-rw-r--r-- 1 tech tech  495336 Feb 18 16:53 libidn2.a
-rwxr-xr-x 1 tech tech     981 Feb 18 16:53 libidn2.la*
-rw-r--r-- 1 tech tech 1087566 Feb 18 16:53 libnghttp2.a
-rwxr-xr-x 1 tech tech     955 Feb 18 16:53 libnghttp2.la*
-rw-r--r-- 1 tech tech  857712 Feb 18 16:53 libnghttp3.a
-rwxr-xr-x 1 tech tech     954 Feb 18 16:53 libnghttp3.la*
-rw-r--r-- 1 tech tech 1751524 Feb 18 16:53 libngtcp2.a
-rwxr-xr-x 1 tech tech     951 Feb 18 16:53 libngtcp2.la*
-rw-r--r-- 1 tech tech  145234 Feb 18 16:53 libngtcp2_crypto_quictls.a
-rwxr-xr-x 1 tech tech    1059 Feb 18 16:53 libngtcp2_crypto_quictls.la*
-rw-r--r-- 1 tech tech  113182 Feb 18 16:53 libpsl.a
-rwxr-xr-x 1 tech tech     933 Feb 18 16:53 libpsl.la*
-rw-r--r-- 1 tech tech 1759942 Feb 18 16:53 libssh2.a
-rwxr-xr-x 1 tech tech     963 Feb 18 16:53 libssh2.la*
-rw-rw-r-- 1 tech tech 1031452 Mar  6 09:00 libssl.a
-rw-r--r-- 1 tech tech 5690850 Feb 18 16:53 libunistring.a
-rwxr-xr-x 1 tech tech     936 Feb 18 16:53 libunistring.la*
-rw-r--r-- 1 tech tech  136116 Feb 18 16:53 libz.a
-rw-r--r-- 1 tech tech 1223348 Feb 18 16:53 libzstd.a
drwxrwxr-x 3 tech tech    4096 Feb 18 16:53 new_libs/
drwxr-xr-x 2 tech tech    4096 Feb 18 16:53 pkgconfig/
tech@code:~/sanket/curl-static-libs$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants