在 SLES 12-SP2 上构建 openssl 1.0.2p 失败 x86_64

Failed build openssl 1.0.2p on SLES 12-SP2 x86_64

尝试在 SLES 12-SP2 x86_64 上构建 openssl 1.0.2p 但失败了 我 运行 作为标准用户执行以下命令:

cd /usr/src/openssl-1.0.2p
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make

控制台摘录

make[4]: Entering directory '/usr/src/openssl-1.0.2p'
...
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: libcrypto.a(gost_sign.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile.shared:169: recipe for target 'link_a.gnu' failed
make[4]: *** [link_a.gnu] Error 1
make[4]: Leaving directory '/usr/src/openssl-1.0.2p'
Makefile:357: recipe for target 'do_linux-shared' failed
make[3]: *** [do_linux-shared] Error 2
make[3]: Leaving directory '/usr/src/openssl-1.0.2p'
Makefile:310: recipe for target 'libcrypto.so.1.0.0' failed
make[2]: *** [libcrypto.so.1.0.0] Error 2
make[2]: Leaving directory '/usr/src/openssl-1.0.2p'
Makefile:109: recipe for target 'shared' failed
make[1]: *** [shared] Error 2
make[1]: Leaving directory '/usr/src/openssl-1.0.2p/crypto'
Makefile:287: recipe for target 'build_crypto' failed
make: *** [build_crypto] Error 1
tony@linux-31cz:/usr/src/openssl-1.0.2p> 
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib

其次是...

/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
libcrypto.a(gost_sign.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object;
recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
final link failed: Nonrepresentable section on output

这听起来像是您之前构建的但省略了 shared。然后你重新配置并添加了 shared.

您应该执行 make distclean 然后重新开始。执行 distclean,然后 运行 ./config ...make dependsmake 然后 make install.

OpenSSL 1.0.2 需要 make depends,因此请务必包括该步骤。

另请参阅 OpenSSL wiki 上的 Compilation and Installation