Skip to content

Instantly share code, notes, and snippets.

@Anubisss
Last active September 11, 2025 09:47
Show Gist options
  • Select an option

  • Save Anubisss/afea82b97058e418e8030ee35e40f54f to your computer and use it in GitHub Desktop.

Select an option

Save Anubisss/afea82b97058e418e8030ee35e40f54f to your computer and use it in GitHub Desktop.
How to compile statically linked OpenVPN client for ARMv5

How to compile statically linked OpenVPN client for ARMv5

You need to install ARMv5 gcc cross compiler: apt-get install gcc-arm-linux-gnueabi

You have to define a directory (via --prefix) where all of your binaries will be installed (copied). In the guide I use the following: /home/user/vpn_compile

OpenSSL

  1. Download the source: wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz
  2. Extract it and change the working directory: tar -xvf openssl-1.0.2j.tar.gz && cd openssl-1.0.2j
  3. Configure it: ./Configure gcc -static -no-shared --prefix=/home/user/vpn_compile --cross-compile-prefix=arm-linux-gnueabi-
  4. Compile: make
  5. Install: make install

LZO

  1. Download the source: wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
  2. Extract it and change the working directory: tar -xvf lzo-2.09.tar.gz && cd lzo-2.09
  3. Configure it: ./configure --prefix=/home/user/vpn_compile --enable-static --target=arm-linux-gnueabi --host=arm-linux-gnueabi --disable-debug
  4. Compile: make
  5. Install: make install

OpenVPN

  1. Download the source: wget https://swupdate.openvpn.org/community/releases/openvpn-2.3.12.tar.gz
  2. Extract it and change the working directory: tar -xvf openvpn-2.3.12.tar.gz && cd openvpn-2.3.12
  3. Configure it: ./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi --prefix=/home/user/vpn_compile --disable-server --enable-static --disable-shared --disable-debug --disable-plugins OPENSSL_SSL_LIBS="-L/home/user/vpn_compile/lib -lssl" OPENSSL_SSL_CFLAGS="-I/home/user/vpn_compile/include" OPENSSL_CRYPTO_LIBS="-L/home/user/vpn_compile/lib -lcrypto" OPENSSL_CRYPTO_CFLAGS="-I/home/user/vpn_compile/include" LZO_CFLAGS="-I/home/user/vpn_compile/include" LZO_LIBS="-L/home/user/vpn_compile/lib -llzo2"
  4. Compile: make LIBS="-all-static"
  5. Install: make install

Your OpenVPN client is here: /home/user/vpn_compile/sbin/openvpn

Make sure this is what you need:

$ file /home/user/vpn_compile/sbin/openvpn
/home/user/vpn_compile/sbin/openvpn: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=e6fd2008c129fef90ed9826e3ffb9d53e83eb42c, not stripped

Versions

Build system:

$ uname -rm
4.4.0-45-generic x86_64
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
$ arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609

Target system:

$ uname -rm
3.2.34 armv5tejl
$ openvpn --version
OpenVPN 2.3.12 arm-unknown-linux-gnueabi [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Oct 27 2016
library versions: OpenSSL 1.0.2j  26 Sep 2016, LZO 2.09
Originally developed by James Yonan
Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <[email protected]>
Compile time defines: enable_crypto=yes enable_crypto_ofb_cfb=yes enable_debug=no enable_def_auth=yes enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown enable_fast_install=needless enable_fragment=yes enable_http_proxy=yes enable_iproute2=no enable_libtool_lock=yes enable_lzo=yes enable_lzo_stub=no enable_management=yes enable_multi=yes enable_multihome=yes enable_pam_dlopen=no enable_pedantic=no enable_pf=yes enable_pkcs11=no enable_plugin_auth_pam=no enable_plugin_down_root=no enable_plugins=no enable_port_share=yes enable_selinux=no enable_server=no enable_shared=no enable_shared_with_static_runtimes=no enable_small=no enable_socks=yes enable_ssl=yes enable_static=yes enable_strict=no enable_strict_options=no enable_systemd=no enable_win32_dll=yes enable_x509_alt_username=no with_crypto_library=openssl with_gnu_ld=yes with_mem_check=no with_plugindir='$(libdir)/openvpn/plugins' with_sysroot=no
@pexes123
Copy link

pexes123 commented Mar 30, 2025

Static libcapng required for building with OpenVPN 2.6.*:

#libCAP-NG
cd /home/source
wget https://github.com/stevegrubb/libcap-ng/archive/refs/tags/v0.8.5.tar.gz
tar xvzf v0.8.5.tar.gz
cd libcap-ng-0.8.5
./autogen.sh
./configure --prefix=/home/openvpn --enable-static --target=arm-linux-gnueabi --host=arm-linux-gnueabi
make
make install

#OpenVPN 2.6.x add/replace following
./configure ... LIBCAPNG_CFLAGS="-I/home/openvpn/include" LIBCAPNG_LIBS="-L/home/openvpn/lib -lcap-ng ..."
make LIBS="-all-static -lcap-ng"

you can get rid of

checking for LIBCAPNG... no
configure: error: libcap-ng package not found. Is the development package and pkg-config installed?

with sudo apt install libcap-ng-dev, but cannot avoid make LIBS="-all-static" to fail with

/home/source/openvpn-2.6.13/src/openvpn/platform.c:246: undefined reference to `capng_clear'
/usr/bin/ld: /home/source/openvpn-2.6.13/src/openvpn/platform.c:247: undefined reference to `capng_update'
/usr/bin/ld: /home/source/openvpn-2.6.13/src/openvpn/platform.c:257: undefined reference to `capng_change_id'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:670: openvpn] Error 1
make[3]: Leaving directory '/home/source/openvpn-2.6.13/src/openvpn'
make[2]: *** [Makefile:439: all-recursive] Error 1
make[2]: Leaving directory '/home/source/openvpn-2.6.13/src'
make[1]: *** [Makefile:617: all-recursive] Error 1
make[1]: Leaving directory '/home/source/openvpn-2.6.13'
make: *** [Makefile:505: all] Error 2

refer: OpenVPN/openvpn#586

@enricosuardi
Copy link

I managed to succesfully build OpenVPN 2.6.14 for MIPS architecture on a clean Debian 12 machine
The final binary can be found at /work/vpn_compile/sbin/openvpn

apt update
apt install -y wget git net-tools build-essential autoconf pkg-config libtool gcc-mips-linux-gnu bison flex

mkdir /work
cd /work


# OpenSSL
wget https://github.com/openssl/openssl/releases/download/openssl-3.0.17/openssl-3.0.17.tar.gz
tar -xvf openssl-3.0.17.tar.gz
cd openssl-3.0.17

./Configure gcc -static -no-shared --prefix=/work/vpn_compile --cross-compile-prefix=mips-linux-gnu-
make -j24
make install_sw

cd ..


# LZO
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
tar -xvf lzo-2.09.tar.gz
cd lzo-2.09

./configure --prefix=/work/vpn_compile --enable-static --disable-shared --target=mips-linux-gnu --host=mips-linux-gnu --disable-debug
make -j24
make install

cd ..


# LZ4
wget https://github.com/lz4/lz4/archive/v1.9.2.tar.gz
tar xvzf v1.9.2.tar.gz
cd lz4-1.9.2

make BUILD_STATIC=yes CC=mips-linux-gnu-gcc DLLTOOL=mips-linux-gnu-dlltool OS=mips-linux-gnu -j24
PREFIX=/work/vpn_compile make install

cd ..

# libcap-ng
wget https://github.com/stevegrubb/libcap-ng/archive/refs/tags/v0.8.5.tar.gz
tar xvzf v0.8.5.tar.gz
cd libcap-ng-0.8.5

./autogen.sh
./configure --prefix=/work/vpn_compile --enable-static --disable-shared --target=mips-linux-gnu --host=mips-linux-gnu
make -j24
make install

cd ..


# libnl-3 (641cd0e77761ed44f1d19dd073766c99732ddd5a)
git clone https://github.com/thom311/libnl
cd libnl

./autogen.sh
./configure --prefix=/work/vpn_compile --enable-static --disable-shared --target=mips-linux-gnu --host=mips-linux-gnu
make -j24
make install

cd ..


# OpenVPN
wget https://swupdate.openvpn.org/community/releases/openvpn-2.6.14.tar.gz
tar -xvf openvpn-2.6.14.tar.gz
cd openvpn-2.6.14

./configure --target=mips-linux-gnu --host=mips-linux-gnu --prefix=/work/vpn_compile --enable-static --disable-shared --disable-debug --disable-plugins OPENSSL_LIBS="-L/work/vpn_compile/lib -lssl" OPENSSL_CFLAGS="-I/work/vpn_compile/include" OPENSSL_CRYPTO_LIBS="-L/work/vpn_compile/lib -lcrypto" OPENSSL_CRYPTO_CFLAGS="-I/work/vpn_compile/include" LZO_CFLAGS="-I/work/vpn_compile/include" LZO_LIBS="-L/work/vpn_compile/lib -llzo2" LZ4_CFLAGS="-I/work/vpn_compile/include" LZ4_LIBS="-L/work/vpn_compile/lib -llz4" LIBNL_GENL_CFLAGS="-I/work/vpn_compile/include" LIBNL_GENL_LIBS="-L/work/vpn_compile/lib -lnl-genl-3" LIBCAPNG_CFLAGS="-I/work/vpn_compile/include" LIBCAPNG_LIBS="-L/work/vpn_compile/lib -lcap-ng" CPPFLAGS="-I/work/vpn_compile/include/libnl3"

make LIBS="-L/work/vpn_compile/lib -all-static -lssl -lcrypto -llzo2 -llz4 -lcap-ng -lnl-3 -lnl-genl-3" -j24
make install

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