我正在为某个类编写一些C代码,并且编译器遇到了问题,需要在make文件中完成该问题,当它运行时,它总是会给出错误
usr/bin/ld: main.o: relocation R_X86_64_32S against symbol "integrand" can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: integration.o: relocation R_X86_64_32S against ".rodata" can not be used when making a shared object; recompile with -fPIC
我试图以多种方式更改makefile来修复Linux系统上的此错误,但可惜它仍然无济于事。
all: main.o integration.o libintegration.so
gcc -fPIC main.o integration.o libintegration.so -o target_bin
libintegration.so: main.o integration.o
gcc main.o integration.o -shared -o libintegration.so
main.o: main.c integration.h
gcc -I . -c main.c
integration.o: integration.c integration.h
gcc -I . -c integration.c
clean:
rm -rf *.o *.so
rm target_bin
谢谢您可以提供的帮助
答案 0 :(得分:0)
使用fpic编译main.c和Integration.c。