How to cross-compile OpenVPN to an old kernel

1

I'm trying to build the VPN client for my NAS which is an ARMv5 CPU with Linux 2.6:

Linux OSS117 2.6.22.18 #15 Wed May 25 15:23:11 CST 2011 armv5tejl GNU/Linux

The compilation machine is a Debian 9 x86_64:

Linux dikkenek 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux

I have basically followed these steps (compile instructions for openssl, libzo and openvpn) which work perfectly well, but the program refuses to run on the target host because the kernel is too old:

bicou@OSS117:~$ ./openvpn 
FATAL: kernel too old
Aborted

I have then, according to this answer, retrieved glibc and compiled it with --enable-kernel=2.6.22 which worked like a charm.

I have then modified the OpenVPN makefile using these instructions (I have adapted to use the cross-compiler GCC instead of the system one when searching for file paths, and it works because it points to /usr/lib/gcc-cross instead of the default /usr/lib/gcc) but now the compilation fails with this:

/usr/lib/gcc-cross/arm-linux-gnueabi/6/../../../../arm-linux-gnueabi/bin/ld: /home/bicou/dns-325-cross/bin/lib/libcrypto.a(v3_utl.o): undefined reference to symbol '__isoc99_sscanf@@GLIBC_2.7'
//usr/arm-linux-gnueabi/lib/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:562: recipe for target 'openvpn' failed
make: *** [openvpn] Error 1

So I figured I had to recompile zo and openssl with the dedicated glibc but that doesn't work either (compilation worked though).

I feel I am very close to attaining what I want, but I'm stuck at the link-with-glibc step.

Here are the versions I used:

  • glibc-2.25
  • lzo-2.09
  • openssl-1.0.2j
  • openvpn-2.3.12

Benoit Duffez

Posted 2017-07-02T11:00:06.430

Reputation: 474

I ended up installing a compiler on the target system. That's not exactly what I wanted even if the initial goal was to have OpenVPN running on the NAS. I'm still curious as to how to compile that from the x86 machine. – Benoit Duffez – 2017-07-02T22:57:21.083

No answers