I'm trying to make a dynamic library from source code but getting the following error. I just could not figure out why.
ld: entry.o: relocation R_X86_64_32S against `.text' can not be used when making a shared
object; recompile with -fPIC
entry.o: error adding symbols: Bad value
Makefile:12: recipe for target 'libdune.so' failed
make: *** [libdune.so] Error 1
I have the source code and my Makefile looks like the following
CC = gcc
CFLAGS = -Wall -fPIC -g -O3 -MD
LDFLAGS = -shared
OBJ = entry.o dune.o vsyscall.o elf.o vm.o util.o page.o procmap.o debug.o apic.o
NOFPU_OBJ = trap.o
$(NOFPU_OBJ): EXTRA_FLAGS := -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -msoft-float
all: libdune.so
libdune.so: $(OBJ) $(NOFPU_OBJ)
$(LD) -shared -o $(@) $(OBJ) $(NOFPU_OBJ)
clean:
rm -f *.o test *.d libdune.so
-include *.d
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -o $@ -c $<
“relocation R_X86_64_32S against ” linking Error talks about the almost same problem but in my case, I have the source code that is needed. Any help on how to make it work?