0

I'm trying to build libcrypto.so.1.0.0 on CentOS 7 with gcc 4.8.5 toolchain. I'm getting the error below that I'm not clear what to do with.

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

Any suggestions?

[user@rsn-xp openssl-1.0.0s]$ cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 

[user@rsn-xp openssl-1.0.0s]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[user@rsn-xp openssl-1.0.0s]$ make libcrypto.so.1.0.0
make[1]: Entering directory `/home/user/src/openssl/openssl-1.0.0s'
make[2]: Entering directory `/home/user/src/openssl/openssl-1.0.0s'
/usr/bin/ld: libcrypto.a(e_gost_err.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
libcrypto.a(e_gost_err.o): error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [link_a.gnu] Error 1
make[2]: Leaving directory `/home/user/src/openssl/openssl-1.0.0s'
make[1]: *** [do_linux-shared] Error 2
make[1]: Leaving directory `/home/user/src/openssl/openssl-1.0.0s'
make: *** [libcrypto.so.1.0.0] Error 2
[user@rsn-xp openssl-1.0.0s]$ 
Denis
  • 1,031
  • 3
  • 11
  • 22
  • Add `shared` to your Configure flags. Also see [Compilation and Installation](https://wiki.openssl.org/index.php/Compilation_and_Installation) on the OpenSSL wiki; or the Linux & Unix [INSTALL](https://github.com/openssl/openssl/blob/master/INSTALL) file. Since you have already configured/built once, be sure to `make distclean` to clean all artifacts from previous builds. – jww Dec 16 '17 at 23:43

1 Answers1

-1

The error is more or less clear on what to do now: recompile with -fPIC. So make sure that -fPIC is included in your CFLAGS (e.g. CFLAGS=-fPIC make ...). The underlying problem is, that you (most likely unintentionally) try to mix relocatable and not relocatable code.

Nj0rd
  • 62
  • 1
  • 3
  • Strange....I checked the cflags in the makefile and -fPIC was already there. So I redid make clean and make to confirm that the -fPIC option was being passed in and it was and on top of that, the .so was successfully built. I must have somehow missed a make clean step earlier causing it work from old non-relocatable object files. Thanks. – Denis Dec 16 '17 at 13:39