手动编译OpenSSL:在创建共享库时不能使用符号;用-fPIC重新编译 [英] Manually compile OpenSSL: symbol can not be used when making a shared object; recompile with -fPIC

查看:508
本文介绍了手动编译OpenSSL:在创建共享库时不能使用符号;用-fPIC重新编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的OpenSSL似乎太旧了.而且没有地方可以解释如何安装最新的OpenSSL库.

My OpenSSL seems to be too old. And there's no place where they explain how to install a more recent OpenSSL library.

openssl version -a
OpenSSL 1.0.1t  3 May 2016
built on: Fri Mar 30 13:47:53 2018
platform: debian-amd64
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: gcc -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -DTERMIO -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wa,--noexecstack -Wall -DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
OPENSSLDIR: "/usr/lib/ssl"

当我想手动安装更新的OpenSSL库时,出现此错误:

When I want to manually install a more recent OpenSSL library, I get this error:

root@mycomputer:/local/install/openssl-1.0.2o# ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib

[...compile stuff...]

make[3]: Entering directory `/local/install/openssl-1.0.2o'
make[4]: Entering directory `/local/install/openssl-1.0.2o'
/usr/bin/ld: libcrypto.a(rsaz_exp.o): relocation R_X86_64_32 against `.rodata' 
    can not be used when making a shared object; recompile with -fPIC
libcrypto.a(rsaz_exp.o): could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[4]: *** [link_a.gnu] Error 1
make[4]: Leaving directory `/local/install/openssl-1.0.2o'
make[3]: *** [do_linux-shared] Error 2
make[3]: Leaving directory `/local/install/openssl-1.0.2o'
make[2]: *** [libcrypto.so.1.0.0] Error 2
make[2]: Leaving directory `/local/install/openssl-1.0.2o'
make[1]: *** [shared] Error 2
make[1]: Leaving directory `/local/install/openssl-1.0.2o/crypto'
make: *** [build_crypto] Error 1

推荐答案

链接器错误:

/usr/bin/ld: libcrypto.a(rsaz_exp.o): relocation R_X86_64_32 against `.rodata' 
    can not be used when making a shared object; recompile with -fPIC

表示归档文件libcrypto.a中的目标文件rsaz_exp.o 尚未被编译为位置独立代码",因此必须 链接到共享对象.建议您使用以下命令重新编译该目标文件 -fPIC.这意味着从源代码重建您的libcrypto.a -fPIC编译选项.

is saying that the object file rsaz_exp.o in the archive libcrypto.a has not been compiled as Position Independent Code, and it must be to be linked into a shared object. It suggests you recompile that object file with -fPIC. Which would mean rebuilding your libcrypto.a from source, with the -fPIC compilation option.

如果您不想这样做,请通过共享的libcrypto.so提供链接 代替链接.

If you don't want to do that, provide your linkage with a shared libcrypto.so to link against instead.

这篇关于手动编译OpenSSL:在创建共享库时不能使用符号;用-fPIC重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆