交叉编译openssl-1.0.0生成动态库

2 篇文章 0 订阅

一 编译环境说明:

ubuntu虚拟机: ubuntu-16.04.6-desktop-amd64
编译工具链:arm-linux-gcc-4.5.1

 

二 编译过程

1 生成makefile:
#./config shared --cross-compile-prefix=arm-linux- --prefix=/usr/local/openssl_arm --openssldir=/usr/local/openssl_arm/ssl  os/compiler:gcc  


config命令执行完成后提示:

You gave the option 'shared'.  Normally, that would give you shared libraries.
Unfortunately, the OpenSSL configuration doesn't include shared library support
for this platform yet, so it will pretend you gave the option 'no-shared'.  If
you can inform the developpers (openssl-dev\@openssl.org) how to support shared
libraries on this platform, they will at least look at it and try their best
(but please first make sure you have tried with a current version of OpenSSL).

由于需要编译成动态库,而默认config不支持该平台,因此需要修改Makefile:

SHARED_LIBS=libcrypto.so libssl.so

SHLIB_TARGET=linux-shared


2 编译生成库:

#make


报错:

../libcrypto.so: undefined reference to `ENGINE_load_atalla'
../libcrypto.so: undefined reference to `ENGINE_load_4758cca'
../libcrypto.so: undefined reference to `ENGINE_load_gost'
../libcrypto.so: undefined reference to `ENGINE_load_padlock'
../libcrypto.so: undefined reference to `ENGINE_load_nuron'
../libcrypto.so: undefined reference to `ENGINE_load_sureware'
../libcrypto.so: undefined reference to `ENGINE_load_chil'
../libcrypto.so: undefined reference to `ENGINE_load_cswift'
../libcrypto.so: undefined reference to `ENGINE_load_aep'
../libcrypto.so: undefined reference to `ENGINE_load_ubsec'
collect2: ld returned 1 exit status
../Makefile.shared:171: recipe for target 'link_app.gnu' failed
make[2]: *** [link_app.gnu] Error 1
make[2]: Leaving directory '/home/code/openssl-1.0.0t/apps'
Makefile:156: recipe for target 'openssl' failed
make[1]: *** [openssl] Error 2
make[1]: Leaving directory '/home/code/openssl-1.0.0t/apps'
Makefile:254: recipe for target 'build_apps' failed
make: *** [build_apps] Error 1

修改Makefile,找到 CFLAG 变量,在变量的最后加上:-DOPENSSL_NO_STATIC_ENGINE 保存退出,再编译:

#make clean
#make

即可生成libssl.so、libssl.so.1.0.0、libcrypto.so和libcrypto.so.1.0.0

#make install

这一步会报如下错误,但其实动态库已经成功生成在当前目录下,忽略该错误,直接使用动态库即可。

cp: cannot stat 'lib4758cca.bad': No such file or directory
Makefile:107: recipe for target 'install' failed
make[1]: *** [install] Error 1
make[1]: Leaving directory '/home/code/openssl-1.0.0t/engines'
Makefile:494: recipe for target 'install_sw' failed
make: *** [install_sw] Error 1

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
交叉编译openssl-1.1.1动态库,你需要按照以下步骤进行操作: 1. 确保你的系统已经安装好交叉编译工具链。工具链通常由GNU Compiler Collection (GCC)和相关工具组成,负责将代码编译为目标架构所需的机器代码。 2. 下载openssl-1.1.1源代码包,并解压到本地目录中。 3. 进入解压后的源代码目录,打开命令行终端。 4. 设置交叉编译的环境变量。根据你的交叉编译工具链和目标架构的不同,设置对应的环境变量,例如CC、CROSS_COMPILE、AR等。 5. 执行配置命令,用来生成编译所需的Makefile。通常的配置命令为:./configure --prefix=目标安装路径。 6. 执行make命令进行编译,根据系统性能不同,编译时间可能会有所不同。 7. 执行make install命令,将编译好的动态库安装到指定目录下。 8. 检查安装是否成功。在目标安装路径下查看是否存在libcrypto.so和libssl.so文件,这些文件就是编译生成动态库。 注意事项: - 在交叉编译过程中,可能会遇到一些问题,例如缺少相关依赖库、环境变量错误等,需要根据具体情况进行解决。 - 如果你的目标架构是嵌入式设备或者特定平台,可能还需要进行额外的配置和调整才能正确交叉编译动态库。 - 在进行交叉编译时,最好参考openssl官方文档或者相关教程,以确保正确的编译结果和使用方法。 以上就是关于如何交叉编译openssl-1.1.1动态库的步骤和注意事项的回答,希望能对你有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值