openssl编译笔记

本文记录windows VS 2015环境、ubuntu16.04系统编译openssl-1.0.1t。

一、准备工作

MinGW、VS 2015和openssl下载从略。
下载nmake,放到MinGW的任意bin目录下。

二、windows

1
2
3
4
5
perl Configure VC-WIN64A
ms\do_win64a
nmake -f ms\ntdll.mak
cd out32dll
..\ms\test

三、ubuntu 16.04 64bit

编译命令:

1
2
3
4
./Configure linux-x86_64 --prefix=/home/latelee/bin/openssl-bin
make depend
make -j
make install

得到的静态库位于/home/latelee/bin/openssl-bin目录。

四、交叉编译(imx6ul 5.3)

先安装好imx6ul交叉编译器。这里使用的是arm-poky-linux-gnueabi-gcc

1
./Configure linux-armv4 --prefix=/home/latelee/bin/openssl-arm-bin

修改生成的Makefile,具体如下:

1
2
3
4
CC= arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/latelee/bin/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi
AR= arm-poky-linux-gnueabi-ar $(ARFLAGS) r
RANLIB= arm-poky-linux-gnueabi-ranlib
NM= arm-poky-linux-gnueabi-nm

编译安装:

1
2
3
make depend
make -j
make install

五、交叉编译(imx6ul 4.6)

先安装好imx6ul交叉编译器。这里使用的是
arm-linux-gcc

配置:

1
./Configure linux-armv4 --prefix=/home/latelee/bin/openssl-arm-bin

修改生成的Makefile,具体如下:

1
2
3
4
CC= arm-linux-gcc
AR= arm-linux-ar $(ARFLAGS) r
RANLIB= arm-linux-ranlib
NM= arm-linux-nm

注:如果在./Configure阶段指定交叉编译器的话,会有如下提示:

1
2
./Configure linux-armv4 --prefix=/home/latelee/bin/openssl-arm-bin CC=arm-linux-gcc RANLIB=arm-linux-ranlib AR=arm-linux-ar
target already defined - linux-armv4 (offending arg: CC=arm-linux-gcc)

如果不使用linux-armv4,则会提示:

1
2
3
4
5
6
7
8
./Configure --prefix=/home/latelee/bin/openssl-arm-bin CC=arm-linux-gcc
Configuring for CC=arm-linux-gcc
Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimental-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]

pick os/compiler from:
BC-32 BS2000-OSD BSD-generi
....
NOTE: If in doubt, on Unix-ish systems use './config'.

综上,直接修改生成的Makefile似乎更好。

编译安装:

1
2
3
make depend
make -j
make install

  • 本文作者:李迟
  • 版权声明:原创文章,版权归署名作者,转载建议注明出处(当然不注明亦可)。
  • 本文链接:/toolslib/openssl-compile.html