0

Hello everyone im trying to compile in Kali linux. Here is 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

but it says an error in linking stage. The error:

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
jww
  • 97,681
  • 90
  • 411
  • 885
Mr.Mystery
  • 19
  • 1
  • 2
    Have you tried recompiling with `-fPIC` as the error message suggests? – super Sep 02 '18 at 12:34
  • 1
    Possible duplicate of [How to recompile with -fPIC](https://stackoverflow.com/q/13812185/608639) – jww Sep 02 '18 at 13:08
  • 1
    *+1* for asking a Kali question that has to do with programming and development. Those are rare for this tag. – jww Sep 02 '18 at 13:08

0 Answers0