大家好,我正在尝试在Kali Linux中进行编译。这是makefile:
program: main.o matrix.o rational.o
g++ -Wall -Wextra -Werror main.o matrix.o rational.o -o program
main.o: main.cpp vector.h
g++ -Wall -Wextra -Werror -c main.cpp -o main.o -std=c++11
matrix.o: matrix.cpp matrix.h
g++ -Wall -Wextra -Werror-c matrix.cpp -o matrix.o -std=c++11
rational.o: rational.cpp rational.h
g++ -Wall -Wextra -Werror -c rational.cpp -o rational.o -std=c++11
但是它表示链接阶段出错。错误:
g++ -Wall -Wextra -Werror main.o matrix.o rational.o -o program
/usr/bin/ld: main.o: relocation R_X86_64_32 against symbol `_ZSt4cout@@GLIBCXX_3.4'
can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [Makefile:2: program] Error 1