error in 64 bit Linux make

In doing a make of a 64 bit .so dynamic library for Linux on Ubuntu Linux 14.04, an error occurs after all objects have been compiled:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: relocation R_X86_64_32 against `TMC_END’ can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

How can I correct this error?

Bob

There are many discussions about this on the internet. The problem is with the default installation of OpenSLL, which has to do with security. The suggested solution is to reinstall OpenSLL with a shared option. This does not appear to be straight-forward.

Bob

Do you use -fPIC for building?

I tried again, adding -fPIC, and got the exact same error.

I found the solution in:

http://stackoverflow.com/questions/6634387/c-statically-linked-shared-library

I used:

CC = g++ -m64 -fPIC

all: $(OBJS)

$(CC) $(CFLAGS) -shared -o libDecimalPlugin.so $(OBJS) -Bstatic

That worked. It fails if -static is used instead of -Bstatic.

I was able to create a working 64 bit Xojo application with the resulting Decimal plugin.