交叉编译openssl-1.0.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

猜你喜欢

转载自blog.csdn.net/shzwfq/article/details/88661625