使用 -fPIE 标志重新编译无法解决错误

时间:2021-05-13 15:00:36

标签: c++ makefile

我正在尝试在 WSL 上使用其 makefile 编译 this app。但我收到以下错误:

g++ -g -Wall -ansi pendulumSystem.o TimeStepper.o particleSystem.o ClothSystem.o simpleSystem.o camera.o main.o vecmath/src/Vector3f.o vecmath/src/Vector2f.o vecmath/src/Matrix3f.o vecmath/src/Matrix4f.o vecmath/src/Vector4f.o vecmath/src/Quat4f.o vecmath/src/Matrix2f.o -o a3 -L. -lRK4 -lglut -lGL -lGLU

/usr/bin/ld: ./libRK4.a(RK4.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIE

/usr/bin/ld: ./libRK4.a(RK4.o): relocation R_X86_64_PC32 against symbol `_Znwm@@GLIBCXX_3.4' can not be used when making a PIE object; recompile with -fPIE

/usr/bin/ld: final link failed: bad value

collect2: error: ld returned 1 exit status
make: *** [Makefile:15: a3] Error 1

我尝试编辑我的 makefile 以包含如下所示的标志,但它仍然给我相同的错误消息。

INCFLAGS  = -I vecmath/include
INCFLAGS += -I /usr/include/GL

LINKFLAGS = -L. -lRK4 -lglut -lGL -lGLU
CFLAGS    = -g -Wall -ansi -fPIE
CC        = g++
SRCS      = $(wildcard *.cpp)
SRCS     += $(wildcard vecmath/src/*.cpp)
OBJS      = $(SRCS:.cpp=.o)
PROG      = a3

all: $(SRCS) $(PROG)

$(PROG): $(OBJS)
        $(CC) $(CFLAGS) $(OBJS) -o $@ $(LINKFLAGS)

.cpp.o:
        $(CC) $(CFLAGS) $< -c -o $@ $(INCFLAGS)

depend:
        makedepend $(INCFLAGS) -Y $(SRCS)

clean:
        rm $(OBJS) $(PROG)

会不会是提供的 libRK4.a 文件没有使用 -fPIE 标志编译?

0 个答案:

没有答案