As it seems gcc is trying to produce a position-independent executable ("shared object" is the hint), tell it not to:
g++ --std=c++11 -no-pie -Iincludes parser.cpp lib/main-parser.o lib/lib.a
It seems that g++
produces position-independent executables by default on your system. Other systems would require -pie
to do so. Using -no-pie
should create a "regular" (position dependent) executable.
(The error is a result of trying to link an object file that was compiled as non-position-independent into an executable that is supposed to be position-independent).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…