Skip to content

Instantly share code, notes, and snippets.

@0neday
Last active October 12, 2024 02:20
Show Gist options
  • Save 0neday/2c820af5acbf90e48a8f1f2b9abf01a6 to your computer and use it in GitHub Desktop.
Save 0neday/2c820af5acbf90e48a8f1f2b9abf01a6 to your computer and use it in GitHub Desktop.
Cross compile statically stunnel for aarch64
### just for arm64
````
BASE=`pwd`
## cross-compile toolchain
git clone https://github.com/0neday/buildroot
cd buildroot
make menuconfig
### select aarch64 and enable ssp , c++ support
make -j$(nproc) toolchain
cd $BASE
## zlib
wget -c https://zlib.net/zlib-1.2.13.tar.gz
tar -xzvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
CC=aarch64-linux-gcc ./configure --prefix=/gl-inet/dists/zlib
make -j$(nproc) && make install
cd $BASE
## openssl, enable threads
wget -c https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz
tar -xzvf OpenSSL_1_1_1t.tar.gz
cd openssl-OpenSSL_1_1_1t
CC=aarch64-linux-gcc ./Configure --prefix=/gl-inet/dists/openssl-v1.1.1t linux-aarch64 zlib threads \
--with-zlib-lib=/gl-inet/dists/zlib/lib --with-zlib-include=/gl-inet/dists/zlib/include
make -j$(nproc) && make install
cd $BASE
## stunnel
wget -c https://www.stunnel.org/downloads/stunnel-5.69.tar.gz
tar -xzvf stunnel-5.69.tar.gz
cd stunnel-5.69
# refer here https://github.com/jirutka/stunnel-static/blob/master/build.sh
sed -i 's/^stunnel_LDFLAGS = /&-all-static /' src/Makefile.in
CC=aarch64-linux-gcc LDFLAGS="-L/gl-inet/dists/zlib/lib/ -lz" CFLAGS="-I/gl-inet/dists/zlib/include" \
./configure --with-threads=pthread --disable-libwrap --disable-fips --host=aarch64-linux \
--prefix=/gl-inet/dists/stunnel --with-ssl=/gl-inet/dists/openssl-v1.1.1t
make -j$(nproc) && make install
cd $BASE
@0neday
Copy link
Author

0neday commented Apr 30, 2021

for x86_64, add --enable-static-nss for glibc. and select kernel header 4.9, to fix
erorr
warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
0neday/buildroot@7409896

@0neday
Copy link
Author

0neday commented Jan 4, 2023

just for x86

BASE=`pwd`

## cross-compile toolchain
git clone https://github.com/0neday/buildroot
cd buildroot
make menuconfig
### select x86_64, glibc and enable ssp , c++ support
make -j$(nproc)  toolchain
cd $BASE

## zlib
wget -c https://zlib.net/zlib-1.2.13.tar.gz
tar -xzvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
CC=x86_64-buildroot-linux-gnu-gcc ./configure --prefix=/mnt/dists/zlib
make -j$(nproc) && make install
cd $BASE

## openssl, enable threads
wget -c https://github.com/openssl/openssl/archive/OpenSSL_1_1_1t.tar.gz
tar -xzvf OpenSSL_1_1_1t.tar.gz
cd openssl-OpenSSL_1_1_1t
CC=x86_64-buildroot-linux-gnu-gcc ./Configure --prefix=/mnt/dists/openssl-v1.1.1t linux-x86_64 zlib threads \
--with-zlib-lib=/mnt/dists/zlib/lib --with-zlib-include=/mnt/dists/zlib/include
make -j$(nproc) && make install
cd $BASE

## stunnel
wget   -c https://www.stunnel.org/downloads/stunnel-5.69.tar.gz
tar -xzvf stunnel-5.69.tar.gz
cd stunnel-5.69
# refer here https://github.com/jirutka/stunnel-static/blob/master/build.sh
sed -i 's/^stunnel_LDFLAGS = /&-all-static /' src/Makefile.in
CC=x86_64-buildroot-linux-gnu-gcc LDFLAGS="-L/mnt/dists/zlib/lib/ -lz" CFLAGS="-I/mnt/dists/zlib/include" \
./configure --with-threads=pthread --disable-libwrap --disable-fips --host=x86_64-linux \
--prefix=/mnt/dists/stunnel  --with-ssl=/mnt/dists/openssl-v1.1.1t
make -j$(nproc) && make install
cd $BASE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment