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

Cannot Compile Socat binaries #45

Open
natig0ng0 opened this issue Apr 21, 2023 · 2 comments
Open

Cannot Compile Socat binaries #45

natig0ng0 opened this issue Apr 21, 2023 · 2 comments

Comments

@natig0ng0
Copy link

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

  • cd openssl-1.1.0f
  • CC='/usr/bin/gcc -static'
  • ./Configure no-shared no-async linux-x86_64
    "glob" is not exported by the File::Glob module
    Can't continue after import errors at /usr/lib/perl5/core_perl/File/Glob.pm line 42.
    BEGIN failed--compilation aborted at ./Configure line 17.
    Screenshot 2023-04-21 at 11 31 27 PM
@jingjingxyk
Copy link

jingjingxyk commented May 7, 2023

@Nathan1001 example

static build openssl v1

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

reference: swoole/swoole-cli@3487ee3?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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants