2

我有一个项目,我使用 -lcblas 标志链接到 BLAS 库。它曾经编译得很好,直到将我的系统升级到 Ubuntu 18.04 和 GCC 7.3.0 之后。无论如何,编译命令是

g++ -o @$ benchmark.o mine.o -lcblas

这会产生错误

/usr/bin/x86_64-linux-gnu-ld: benchmark.o: relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output

这个问题可能是重复的,但我无法将解决方案翻译为与我的问题类似的其他问题。

4

1 回答 1

2

制作 PIE 对象时不能使用;使用 -fPIC 重新编译

Ubuntu 18.04:g++-5 (5.5)、g++-6、g++-7 都默认配置了 PIE。

要么使用g++ -no-pie -o ... ..,要么使用 g++-4.8:sudo apt install g++-4.8。参考。如何将 gcc 配置为默认使用 -no-pie?


Ubuntu 16.04 和 18.04 的额外编译器 → “无 PIE” g++54 : gcc54-c++_5.4.0-ubuntu16_amd64.deb→ 提供 /usr/bin/{gcc54, g++54, gfortran54}。链接:https ://drive.google.com/file/d/1ptHLaZXImpeMzq4xuuGGn5VjrvxNSop3/view?usp=sharing

更多 gcc(无 PIE)https://drive.google.com/drive/folders/1xVEATaYAwqvseBzYxKDzJoZ4-Hc_XOJm?usp=sharing

于 2018-05-08T11:45:02.383 回答