Hi, When building a certain software, I receive this error message during the link stage:
/usr/bin/ld: _obj/device/r4300/x86_64/dyna_start.o: relocation R_X86_64_PC32 against undefined symbol `g_dev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
Since it said to recompile with -fPIC, I followed the instructions.
I opened the Makefile and added it to all the rules, that became:
And then tried to build the software again. But now I am receiving:
1 2 3 4 5
Makefile:322: Using SDL 1.2 libraries
CC _obj/api/callbacks.o
CC _obj/api/common.o
gcc: error: _obj/api/common.o: No such file or directory
gcc: error: _obj/api/callbacks.o: No such file or directory
So, what's going on now?
Be sure that
every
object file (
.o
) or static library (
.a
) you are linking in has been compiled with
-fPIC
.
Maybe adding
-Wl,--trace
to your gcc linker command can help to show more details.
Also, be sure you re-build your files after Makefile changes. For example, run
make -B
in order to force a "full" rebuild.
Last edited on
I added -Wl,--trace, but it didn't provide me any hints about it.
The last lines are these:
1 2 3 4 5 6 7 8 9 10 11
-lstdc++ (/media/34GB/Arquivos-de-Programas-Linux/Gcc-4.9.4/lib/gcc/x86_64-linux-gnu/4.9.4/../../../../lib64/libstdc++.so)
-lm (/usr/lib/../lib64/libm.so)
-lgcc_s (/media/34GB/Arquivos-de-Programas-Linux/Gcc-4.9.4/lib/gcc/x86_64-linux-gnu/4.9.4/../../../../lib64/libgcc_s.so)
/lib64/libc.so.6
/lib64/ld-linux-x86-64.so.2
-lgcc_s (/media/34GB/Arquivos-de-Programas-Linux/Gcc-4.9.4/lib/gcc/x86_64-linux-gnu/4.9.4/../../../../lib64/libgcc_s.so)
/media/34GB/Arquivos-de-Programas-Linux/Gcc-4.9.4/lib/gcc/x86_64-linux-gnu/4.9.4/crtfastmath.o
/media/34GB/Arquivos-de-Programas-Linux/Gcc-4.9.4/lib/gcc/x86_64-linux-gnu/4.9.4/crtendS.o
/usr/lib/../lib64/crtn.o
/usr/bin/ld: _obj/device/r4300/x86_64/dyna_start.o: relocation R_X86_64_PC32 against undefined symbol `g_dev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
The Makefile's object rules are these:
1 2 3 4
# It is important to disable LTO for this object file
# otherwise we can't extract usefull information from it.
$(ASM_DEFINES_OBJ): $(SRCDIR)/asm_defines/asm_defines.c
$(COMPILE.c) -fno-lto -fPIC -o $@ $<
because it causes a
nasm: fatal: unrecognised output format `PIC
' - use -hf for a list
I did use a make clean before the last attempt. make -B does not work
I think when "compiling" assembly (ASM) code, you cannot and don't need to specify
-fPIC
, because it would be the job of the assembly programmer to ensure that the assembly code itself does
not
use absolute memory addressing...
Last edited on