gmssl 编译过程- linux pc版本、windows pc版本和嵌入式linux版本
gmssl 编译过程- linux pc版本、windows pc版本和嵌入式linux版本前言一 gmssllinux pc版编译二gmsslwindows pc版编译三gmsslmips开发板的交叉编译前言本文主要讲解gmss的编译过程,包括linux pc版本、windows pc版本和嵌入式linux版本。一 gmssllinux pc版编译按照openssl的方式编译gmssl[root
gmssl 编译过程- linux pc版本、windows pc版本和嵌入式linux版本
前言
本文主要讲解gmss的编译过程,包括linux pc版本、windows pc版本和嵌入式linux版本。
一 gmssl linux pc版编译
按照openssl的方式编译gmssl
[root@username ~]# mkdir /usr/local/gmssl
[root@username ~]# cd gmssl
[root@username GmSSL]# ./config --prefix=/usr/local/gmssl shared zlib-dynamic
[root@username GmSSL]# make && make install
[root@username ~]# chown -R root:username /usr/local/gmssl
[root@username ~]# echo '/usr/local/gmssl/lib' >> /etc/ld.so.conf.d/local.conf && ldconfig
[root@username ~]# ln -s /usr/local/gmssl/include/openssl/ /usr/include/
编译完成后,运行查看版本
[root@username ~]# gmssl version
GmSSL 2.5.4 - OpenSSL 1.1.0d 19 Jun 2019
在目录/usr/local/gmssl/lib下会生成如下4个库
gmssl 的ssl库:
libssl.a libssl.so.1.1
gmssl 的加解密库:
libcrypto.a libcrypto.so.1.1
二 gmssl windows pc版编译
首先参考了如下的文章:
https://blog.csdn.net/kuaxianpan2004/article/details/104397521
1 安装相关工具
(1) 先安装VS2019,安装的时候直接选择了C++桌面开发。
(2) 安装NASM: nasm-2.14.03rc2-installer-x64.exe
(3) 安装ActivePerl : 安装ActivePerl的时候从官网上下载的nsi文件一直安装有问题。找到一个完整版的exe才行。
2 以管理员身份打开Visual Studio Tools下的Developer Command Prompt for vs2017控制台,cd到源码目录下,运行以下命令:
perl Configure VC-WIN32
nmake
nmake install
注意,不能用config文件,这个是在linux 执行用的的,之后执行:nmake既可编译
编译过程有问题:
libcrypto.* libcrypto-1_1.* && EXIT 1)
libcrypto-1_1.def : error LNK2001: 无法解析的外部符号 EVP_get_ciphernames
libcrypto-1_1.def : error LNK2001: 无法解析的外部符号 EVP_get_digestnames
libcrypto.lib : fatal error LNK1120: 2 个无法解析的外部命令
NMAKE : fatal error U1077: “link”: 返回代码“0x1”
按照这个帖子修改可以解决:
https://blog.csdn.net/apianmuse/article/details/107353574
3 编译64位版本
以管理员身份打开Visual Studio Tools下的x64 Native Tools Command Prompt for vs2017控制台,cd到源码目录下,运行以下命令:
perl Configure VC-WIN64A
nmake
nmake install
注意:不能是VC-64. 而是VC-WIN64A
4 测试:
命令行执行 gmssl version可以看到版本信息。
三 gmssl mips开发板的交叉编译
1 目标环境:
cpu : mips MT7628N
系统: openwrt(基于嵌入式linux)
内存: 64MB
存储: 16MB
2 config
./Configure --prefix=/home/yaomingyue/opt/gmssl --cross-compile-prefix=mipsel-openwrt-linux- no-asm shared no-async linux-mips32
修改Makefile ,若有-m32或-m64 字段,直接删除即可
或者
setarch i386 ./Configure no-asm shared no-async --prefix=/home/yaomingyue/opt/gmssl --cross-compile-prefix=mipsel-openwrt-linux- linux-mips32
修改makefile
增加:
export STAGING_DIR=$STAGING_DIR:/home/yaomingyue/tool_chain/toolchain-mipsel_24kec_gcc-4.8-linaro_uClibc-0.9.33.2/bin
2 make
编译时,报错如下错误,此时gmssl的命令行工具编译不出来。但lib库可以编译出来
apps.c:(.text+0x545c): undefined reference to `SSL_get_all_async_fds'
apps.c:(.text+0x54bc): undefined reference to `SSL_get_all_async_fds'
apps/s_server.o: In function `init_ssl_connection':
s_server.c:(.text+0x66c): undefined reference to `SSL_waiting_for_async'
apps/s_server.o: In function `sv_body':
s_server.c:(.text+0xdfc): undefined reference to `SSL_waiting_for_async'
s_server.c:(.text+0x1054): undefined reference to `SSL_waiting_for_async'
apps/s_server.o: In function `www_body':
s_server.c:(.text+0x181c): undefined reference to `SSL_waiting_for_async'
s_server.c:(.text+0x2284): undefined reference to `SSL_waiting_for_async
因为在之前的config时,没有增加no-async选项,增加后,不在报该问题。
no-async表示关闭异步,但是之后编译还会有其它问题,注意由于这个导致的问题,基本都可以通过修改注释让其编译通过,实际使用不会有问题。
问题解决参考https://blog.csdn.net/baidu_19348579/article/details/109049351
3 测试
将编译出来的libssl.so.1.1 、 libcrypto.so.1.1和gmssl命令工具拷贝到开发板中,将两个库放到 /usr/lib/下
运行: gmssl version ,可以正常出现版本信息。
注意: 此时编译出来的库比较大,因为嵌入式开发板的存储有限,后续需要进行裁剪。
更多推荐
所有评论(0)