Arch系统下FLINT/C库安装报错:ld提示-r与-pie无法同时使用
-r and -pie may not be used together I’ve run into this exact issue before with older C libraries on Arch—here’s what’s going on and how to fix it quickly:
Arch Linux sets GCC to enable position-independent executables (PIE) by default for security reasons, but FLINT 2.4.5 is an older release whose build system doesn’t account for this. The linker error happens because FLINT uses the -r flag (to create relocatable object files) which conflicts with the default -pie linker flag.
Here are two reliable fixes:
1. Quick Temporary Fix: Override Flags When Running Make
Just pass the PIE-disabling flags directly to make—this avoids editing any source files:
make CFLAGS="-fno-pie" LDFLAGS="-no-pie" && sudo make install
You’ll need sudo for make install since it installs files to system-wide directories like /usr/local/lib and /usr/local/include.
2. Permanent Fix: Edit FLINT’s Root Makefile
If you plan to recompile FLINT later or want the flags baked into the build:
- Open the
Makefilein yourflint-2.4.5directory - Find the lines defining
CFLAGSandLDFLAGS - Add
-fno-pieto theCFLAGSline, and-no-pieto theLDFLAGSline. For example:CFLAGS = -O2 -fno-pie -Wall ... (keep existing flags) LDFLAGS = -no-pie ... (keep existing flags) - Save the file, then run
make && sudo make installas normal.
Once you’ve completed either fix, test the installation by compiling a small program that links against FLINT to confirm everything works as expected.
内容的提问来源于stack exchange,提问作者user9111001

