I have a project where I link to the BLAS library using the -lcblas flag. It used to compile fine, until after upgrading my system to Ubuntu 18.04 and GCC 7.3.0. Anyway, the compile command is
g++ -o @$ benchmark.o mine.o -lcblas
which yields the error
/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
This issue is possibly a duplicate, but I haven't been able to translate the solutions to other similar problems to my issue.
can not be used when making a PIE object; recompile with -fPIC
Ubuntu 18.04 : g++-5 (5.5), g++-6, g++-7 are all configured with PIE by default.
Either use g++ -no-pie -o ... ..
, or use g++-4.8 : sudo apt install g++-4.8 . Ref. How to configure gcc to use -no-pie by default?
Extra compiler for Ubuntu 16.04 and 18.04 → The "no PIE" g++54 : gcc54-c++_5.4.0-ubuntu16_amd64.deb
→ Provides /usr/bin/{gcc54, g++54, gfortran54}. Link : https://drive.google.com/file/d/1ptHLaZXImpeMzq4xuuGGn5VjrvxNSop3/view?usp=sharing
More gcc (no PIE) https://drive.google.com/drive/folders/1xVEATaYAwqvseBzYxKDzJoZ4-Hc_XOJm?usp=sharing