mipsel-openwrt-linux交叉编译openssl-1.0.2l
原创
©著作权归作者所有:来自51CTO博客作者逍遥游10的原创作品,请联系作者获取转载授权,否则将追究法律责任
mipsel-openwrt-linux交叉编译openssl-1.0.2l
注意:以下内容基于openssl-1.0.2l,不同版本的交叉编译方式可能存在差异。
1.下载及解压
wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar zxvf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l
2.生成配置文件
进入openssl-1.0.2l根目录下后:
其中config_to_makefile.sh的内容为:
#########################################################################
# File Name: config_to_makefile.sh
# Author: loon
# mail: 2453419889@qq.com
# Created Time: 2018年09月05日 星期三 13时36分09秒
#########################################################################
#!/bin/bash
cd ..
./config no-asm shared --prefix=/home/ubuntu/work/openssl-1.0.2l/mipsel/
执行该shell脚本后就会在openssl-1.0.2l的根目录下生成Makefile文件。
3.修改Makefile文件
打开Makefile进行修改
# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
52 # MFUNC - Make all Malloc/Free/Realloc calls call
53 # CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
54 # call application defined callbacks via CRYPTO_set_mem_functions()
55 # MD5_ASM needs to be defined to use the x86 assembler for MD5
56 # SHA1_ASM needs to be defined to use the x86 assembler for SHA1
57 # RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
58 # Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8. It must
59 # equal 4.
60 # PKCS1_CHECK - pkcs1 tests.
修改CC\AR\RANLIB\NM为交叉编译器所带的即可(记得加路径)。
4.编译和安装
make && make install
5.可能出现的错误
make[1]: Entering directory '/home/ubuntu/work/openssl-1.0.2l/crypto'
/usr/bin/perl ../util/mkbuildinf.pl "/opt/OpenWrt-Toolchain-ramips-mt7628_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-i686/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=pentium -DL_ENDIAN -O3 -fomit-frame-pointer -Wall" "linux-elf" >buildinf.h
/opt/OpenWrt-Toolchain-ramips-mt7628_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-i686/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=pentium -DL_ENDIAN -O3 -fomit-frame-pointer -Wall -c -o cryptlib.o cryptlib.c
mipsel-openwrt-linux-uclibc-gcc.bin: error: unrecognized argument in option '-march=pentium'
mipsel-openwrt-linux-uclibc-gcc.bin: note: valid arguments to '-march=' are: 10000 1004kc 1004kf 1004kf1_1 1004kf2_1 10k 12000 12k 14000 14k 16000 16k 2000 20kc 24kc 24kec 24kef 24kef1_1 24kef2_1 24kefx 24kex 24kf 24kf1_1 24kf2_1 24kfx 24kx 2k 3000 34kc 34kf 34kf1_1 34kf2_1 34kfx 34kn 34kx 3900 3k 4000 4100 4111 4120 4130 4300 4400 4600 4650 4700 4k 4kc 4kec 4kem 4kep 4km 4kp 4ksc 4ksd 5000 5400 5500 5k 5kc 5kf 6000 6k 7000 74kc 74kf 74kf1_1 74kf2_1 74kf3_2 74kfx 74kx 7k 8000 8k 9000 9k from-abi loongson2e loongson2f loongson3a m4k mips1 mips2 mips3 mips32 mips32r2 mips4 mips64 mips64r2 native octeon octeon+ octeon2 orion r10000 r1004kc r1004kf r1004kf1_1 r1004kf2_1 r10k r12000 r12k r14000 r14k r16000 r16k r2000 r20kc r24kc r24kec r24kef r24kef1_1 r24kef2_1 r24kefx r24kex r24kf r24kf1_1 r24kf2_1 r24kfx r24kx r2k r3000 r34kc r34kf r34kf1_1 r34kf2_1 r34kfx r34kn r34kx r3900 r3k r4000 r4100 r4111 r4120 r4130 r4300 r4400 r4600 r4650 r4700 r4k r4kc r4kec r4kem r4kep r4km r4kp r4ksc r4ksd r5000 r5400 r5500 r5k r5kc r5kf r6000 r6k r7000 r74kc r74kf r74kf1_1 r74kf2_1 r74kf3_2 r74kfx r74kx r7k r8000 r8k r9000 r9k rm7000 rm7k rm9000 rm9k sb1 sb1a sr71000 sr71k vr4100 vr4111 vr4120 vr4130 vr4300 vr5000 vr5400 vr5500 vr5k xlp xlr
<builtin>: recipe for target 'cryptlib.o' failed
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory '/home/ubuntu/work/openssl-1.0.2l/crypto'
Makefile:287: recipe for target 'build_crypto' failed
make: *** [build_crypto] Error 1
mipsel-openwrt-linux-uclibc-gcc.bin: error: unrecognized argument in option ‘-march=pentium’,默认取了我的电脑的CPU型号“奔腾”,所以我们需要根据我们板子的CPU型号来换一下,我这里为
cpu model : MIPS 24KEc V5.5
使用vim自带的搜索功能,搜索到所有的march,然后修改CPU型号为24kec。