2022年交叉编译openvpn

参考https://www.ebaina.com/articles/140000002640
参考https://www.cnblogs.com/bai2022/p/12247373.html
参考https://blog.51cto.com/linuxcgi/1966848

1.依赖

依赖于系统时间ntpdate,openssl,libpam,lzo,tun
下载
linux-pam-1.5.2
lzo-2.10
openssl-1.1.1p
openvpn-2.5.7

2.交叉编译lzo

http://www.oberhumer.com/opensource/lzo/#download

2.1 解压

 tar xvf lzo-2.10.tar.gz

2.2 编译

#!/bin/sh

export PATH=$PATH:/opt/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin

INSTALLDIR=/home/reasonss/imx6-new/source/VPN/build

./configure CC=arm-linux-gnueabihf-gcc --host=arm-none-linux-gnueabihf --enable-shared --disable-static --prefix=$INSTALLDIR/lzo/usr

make -j8
make install

3.交叉编译libpam

https://github.com/linux-pam/linux-pam/releases

3.1编译

ci/install-dependencies.sh 
./autogen.sh 

export PATH=$PATH:/opt/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin

INSTALLDIR=/home/reasonss/imx6-new/source/VPN/build

./configure CC=arm-linux-gnueabihf-gcc --host=arm-none-linux-gnueabihf  --prefix=$INSTALLDIR/lzo/usr

make -j8
make install

3.2 编译异常 cannot find -ltirpc

如果已经编译出来了libpam.so,其他不用管它了,用不上

在这里插入图片描述

4.交叉编译libopenssl

https://www.openssl.org/source/
https://www.openssl.org/source/openssl-1.1.1p.tar.gz

4.1编译

#!/bin/sh

export PATH=$PATH:/opt/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
INSTALLDIR=/home/reasonss/imx6-new/source/VPN/build/ssl

./Configure linux-armv4  --cross-compile-prefix=arm-linux-gnueabihf- --prefix=$INSTALLDIR

make -j8
make install

5.交叉编译openvpn

5.1下载

https://openvpn.net/

5.2编译

#!/bin/sh

export PATH=$PATH:/opt/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
INSTALLDIR=/home/reasonss/imx6-new/source/VPN/build/vpn

./configure --host=arm-linux-gnueabihf \
CC=arm-linux-gnueabihf-gcc  \
AR=arm-linux-gnueabihf-ar  \
BANLIB=arm-linux-gnueabihf-ranlib \
LZO_CFLAGS=-I/home/reasonss/imx6-new/source/VPN/build/lzo/usr/include \
LZO_LIBS=-L/home/reasonss/imx6-new/source/VPN/build/lzo/usr/lib \
LIBPAM_CFLAGS=-I/home/reasonss/imx6-new/source/VPN/build/pam/usr/include \
LIBPAM_LIBS=-L/home/reasonss/imx6-new/source/VPN/build/pam/usr/lib \
OPENSSL_CFLAGS=-I/home/reasonss/imx6-new/source/VPN/build/ssl/include \
OPENSSL_LIBS=-L/home/reasonss/imx6-new/source/VPN/build/ssl/lib \
--prefix=$INSTALLDIR

make -j8 
make install

5.3异常

5.3.1 configure: error: OpenSSL version too old

有可能是版本太老,太老就把依赖换一下
但我这个是openssl1.1.1

//依赖的目录调整一下  不要加上ssl/include/ssl/

OPENSSL_CFLAGS=-I/home/reasonss/imx6-new/source/VPN/build/ssl/include 

5.3.2 undefined reference to `X509_NAME_entry_count’

vim  source/VPN/openvpn-2.5.7/config.status
S["LDFLAGS"]="-L/home/reasonss/imx6-new/source/VPN/build/lzo/usr/lib -L/home/reasonss/imx6-new/source/VPN/build/pam/usr/lib -L/home/reasonss/imx6-new/source/VPN/build/ssl/lib"
S["LIBS"]="-lssl -lcrypto -llzo2 -ldl"
make 

5.3.3 auth-pam.c:33:31: fatal error: security/pam_appl.h: No such file or directory

#把文件位置调整一下  
#原本的路径是
/home/reasonss/imx6-new/source/VPN/build/pam/usr/include/pam_appl.h
#新建一个文件夹
cd /home/reasonss/imx6-new/source/VPN/build/pam/usr/include/
mkdir security
#把原来的头文件移动到security
/home/reasonss/imx6-new/source/VPN/build/pam/usr/include/security/pam_appl.h

5.4 编译成功

在这里插入图片描述

6.测试

6.1 简单调用程序

在这里插入图片描述

6.2 加载证书登陆

openvpn --config aliyun_openvpn_remote_access_l3.ovpn

在这里插入图片描述

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

交叉编译之王 hahaha

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值