andrew-d / static-binaries

Various *nix tools built as statically-linked binaries
Other
3.1k stars 566 forks source link

Cannot Compile Socat binaries #45

Open natig0ng0 opened 1 year ago

natig0ng0 commented 1 year ago

I am currently facing an issue trying to build the socat static binaries. Please find below the issue.

openssl-1.1.0f/e_os.h

jingjingxyk commented 1 year ago

@nathan1001 example

static build openssl v1


 ./config  -static --static no-shared --prefix=/usr/openssl --libdir=/usr/openssl/lib

reference: https://github.com/swoole/swoole-cli/commit/3487ee3fbf6818277cb74a6ba3f2a3beb1977c93?diff=unified#diff-2344faf90e866061ed322e55942bfec6fc0d342a76d4221e3fd3c9b887af0b14R18

socat depend readline libiconv openssl ;

libiconv

./configure --prefix=/usr/libiconv enable_static=yes enable_shared=no

reference: https://github.com/swoole/swoole-cli/blob/f915eb555eae30276d7e415e7d4dc34775cd8946/conf.d/iconv.php#L16

readline

./configure \
                --prefix=/usr/readline \
                --enable-static \
                --disable-shared 

reference: https://github.com/swoole/swoole-cli/blob/f915eb555eae30276d7e415e7d4dc34775cd8946/conf.d/readline.php#L87

build static socat

            PACKAGES='openssl readline'
            CPPFLAGS="$(pkg-config  --cflags-only-I  --static $PACKAGES)" \
            LDFLAGS="$(pkg-config   --libs-only-L    --static $PACKAGES)" \
            LIBS="$(pkg-config      --libs-only-l    --static $PACKAGES)" \
            CFLAGS="-static -O2 -Wall -fPIC  -DWITH_OPENSSL" \
            ./configure \
            --prefix=/usr/socat \
            --enable-readline \
            --enable-openssl-base=/usr/openssl

test and verify

wget https://curl.se/ca/cacert.pem

./socat -d -d TCP4-LISTEN:8016,reuseaddr,fork ssl:example.com:443,verify=1,\
snihost=example.com,commonname=example.com,\
openssl-min-proto-version=TLS1.3,openssl-max-proto-version=TLS1.3,cafile=/root/cacert.pem

reference:

more info: https://github.com/aledbf/socat-static-binary/blob/master/build.sh https://github.com/andrew-d/static-binaries/blob/master/socat/build.sh

Azathothas commented 3 weeks ago

Sorry to hijack this Issue, but I have been working on a successor project: https://github.com/Azathothas/Toolpacks There's already over 2000+ precompiled binaries available to download, including socat:

!#aarch64 Linux
#https://github.com/Azathothas/Toolpacks/tree/main/.github/scripts/aarch64_Linux/bins/socat.sh
https://bin.ajam.dev/aarch64_arm64_Linux/socat

!#x86_64 Linux
#https://github.com/Azathothas/Toolpacks/blob/main/.github/scripts/x86_64_Linux/bins/socat.sh
https://bin.ajam.dev/x86_64_Linux/socat