当前位置: 首页 > news >正文

Ubuntu系统下交叉编译openssl

一、参考资料

OpenSSL&&libcurl库的交叉编译 - hesetone - 博客园

二、准备工作

1. 编译环境

  • 宿主机:Ubuntu 20.04.6 LTS
  • Host:ARM32位
  • 交叉编译器:arm-linux-gnueabihf-gcc-11.1.0

2. 设置交叉编译工具链

在交叉编译之前,需要设置交叉编译工具链的环境变量。

export PATH=/path/to/toolchains/arm-linux-gnueabihf/bin:$PATH

三、交叉编译 openssl

1. 下载源码

GitHub - openssl/openssl: TLS/SSL and crypto library

tar -xvzf openssl-openssl-3.5.0.tar.gz

2. 生成configure配置

setarch i386 ./config no-asm enable-shared --prefix=/path/to/openssl-openssl-3.5.0/arm_install --cross-compile-prefix=arm-linux-gnueabihf- -v

解释说明

  • setarch i386:声明生成的是32位CPU,如果是64位CPU则去除该部分。
  • enable-shared:生成动态连接库。
  • no-asm: 在交叉编译过程中不使用汇编代码,以加速编译过程,且arm不支持汇编代码。

输出示例:

yoyo@yoyo:~/360Downloads/openssl-openssl-3.5.0$ setarch i386 ./config no-asm enable-shared --prefix=/path/to/openssl-openssl-3.5.0/arm_install --cross-compile-prefix=arm-linux-gnueabihf- -v
C compiler: gcc
C compiler vendor: gnu
C compiler version: 1101
Configuring OpenSSL version 3.5.0 for target linux-x86
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************

3. 修改Makefile

PLATFORM=arm
CROSS_COMPILE=arm-linux-gnueabihf-# 如果编译出错,则去掉 `-m32`
CNF_CFLAGS=-pthread # -m32
CNF_CXXFLAGS=-std=c++11 -pthread # -m32

注意:如果 Makefile 中存在 -m32-m64,则删除。

4. 编译安装

make -j8
make install

编译安装之后的文件目录:

yoyo@yoyo:~/360Downloads/openssl-openssl-3.5.0$ tree -L 2 arm_install/
arm_install/
├── bin
│   ├── c_rehash
│   └── openssl
├── include
│   └── openssl
├── lib
│   ├── cmake
│   ├── engines-3
│   ├── libcrypto.a
│   ├── libcrypto.so -> libcrypto.so.3
│   ├── libcrypto.so.3
│   ├── libssl.a
│   ├── libssl.so -> libssl.so.3
│   ├── libssl.so.3
│   ├── ossl-modules
│   └── pkgconfig
├── share
│   ├── doc
│   └── man
└── ssl├── certs├── ct_log_list.cnf├── ct_log_list.cnf.dist├── misc├── openssl.cnf├── openssl.cnf.dist└── private

5. 移植到开发板

cp -arf /path/to/openssl_arm/bin/ /usr/ssl/
cp -arf /path/to/openssl_arm/lib/ /usr/ssl/
cp -arf /path/to/openssl_arm/ssl/ /usr/ssl/
http://www.xdnf.cn/news/921187.html

相关文章:

  • 【在线五子棋对战】二、websocket 服务器搭建
  • 【Qlib】Windows上Qlib安装与初步使用
  • 食品计算—Food Portion Estimation via 3D Object Scaling
  • 运维_集运维linu自动化运维和部署
  • Scrapy爬虫教程(新手)
  • 基于物联网设计的智慧家庭健康医疗系统
  • OpenWrt:使用ALSA实现边录边播
  • ngx_stream_geo_module在传输层实现高性能 IP Region 路由
  • leetcode 3170. 删除星号以后字典序最小的字符串 中等
  • ADVANTEST R3764 66 R3765 67爱德万测试networki connection programming网络程序设计手册
  • c++ —— 内存管理
  • 【题解-洛谷】P1706 全排列问题
  • 前端开发中出现的跨域问题以及解决方案
  • win32相关(消息Hook)
  • 【LLM大模型技术专题】「入门到精通系列教程」基于ai-openai-spring-boot-starter集成开发实战指南
  • Git开发实战
  • Android 相对布局管理器(RelativeLayout)
  • 多模型协同:基于 SAM 分割 + YOLO 检测 + ResNet 分类的工业开关状态实时监控方案
  • ZephyrOS 嵌入式开发Black Pill V1.2之Debug调试器
  • CSS 预处理器与工具
  • Spring中循环依赖问题的解决机制总结
  • ROS2,工作空间中新建了一个python脚本,需要之后作为节点运行。告诉我步骤?
  • 【选配电脑】CPU核显工作机控制预算5000
  • vue · 插槽 | $slots:访问所有命名插槽内容 | 插槽的使用:子组件和父组件如何书写?
  • Bugku-CTF-Web安全最佳刷题路线
  • ubuntu中使用docker
  • HBuilderX安装(uni-app和小程序开发)
  • Qt Quick Layout功能及架构
  • 篇章十 数据结构——Java对象的比较
  • 高频 PCB 技术发展趋势与应用解析