如何解决:用-fPIE错误重新编译?

时间:2020-07-08 07:23:43

标签: c makefile

我试图用makefile编译代码,但这是终端向我显示的错误:

rm -f test/bst_is_not_empty
rm -f test/ht_sepchain_is_not_empty
rm -f *.o test/*.o
cc -Wall -Wextra -std=c11 -pedantic -g -I./include   -c -o test/bst_is_not_empty. test/bst_is_not_empty.c
cc -Wall -Wextra -std=c11 -pedantic -g -I./include   -c -o exam.o exam.c
cc -L./lib  test/bst_is_not_empty.o exam.o  -lm -lupoalglib -o test/bst_is_not_empty
/usr/bin/ld: ./lib/libupoalglib.a(test.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ./lib/libupoalglib.a(bst.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: test/bst_is_not_empty] Error 1

这是makefile:

CFLAGS += -Wall -Wextra -std=c11 -pedantic
CFLAGS += -g
CFLAGS += -I./include
LDFLAGS += -L./lib
LDLIBS += -lm -lupoalglib


.PHONY: all clean

all: test/bst_is_not_empty test/ht_sepchain_is_not_empty

test/bst_is_not_empty: test/bst_is_not_empty.o exam.o

test/ht_sepchain_is_not_empty: test/ht_sepchain_is_not_empty.o exam.o

clean:
    $(RM) test/bst_is_not_empty
    $(RM) test/ht_sepchain_is_not_empty
    $(RM) *.o test/*.o

makefile和所有源文件/头文件都是由我的教授提供的(是一个测试示例,所以...) 我试图弄清楚如何解决这个问题,但对于这个错误我仍然感到困惑

1 个答案:

答案 0 :(得分:0)

尝试使用-fPIC重新编译./lib/libupoalglib.a

相关问题