Search code examples
compilationshared-librariesshared

shared object compilation error


I am trying to compile a library libEncryption.so.

Here is what my make file conatins:

cc -g -w -fPIC  -c -ISource/Header -I//usr/local/ssl/include -L//usr/local/ssl/lib -     lssl -lcrypto Source/Common/C/Encryption.c -DBIT64 -DDBG -DLITTLEENDIAN -DOMS -DRMS
mv Encryption.o Objects/Encryption.o
ld -fPIC -G  Objects/Encryption.o  -L/usr/local/ssl/lib -lssl -lcrypto -o   libEncryption.so

On running this i keep on getting following error

ld: /usr/local/ssl/lib/libcrypto.a(sha1dgst.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value


Solution

  • It's telling you libcrypto.a was not compiled with fPIC.

    You should either rebuild it with -fPIC, or drop the use of -fPIC when compiling your stuff.