How to fix recompile with -fPIC error?


#1

I’m getting the following errors when I try to build my OF project on Ubuntu 16.04.

/usr/bin/x86_64-linux-gnu-ld.gold: error: /home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/kiss/lib/linux64/libkiss.a(kiss_fft.o): requires dynamic R_X86_64_PC32 reloc against 'kiss_fft_stride' which may overflow at runtime; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld.gold: error: /home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a(tess.o): requires dynamic R_X86_64_PC32 reloc against 'tessMeshTessellateMonoRegion' which may overflow at runtime; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld.gold: error: /home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a(geom.o): requires dynamic R_X86_64_PC32 reloc against 'testransEval' which may overflow at runtime; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld.gold: error: /home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a(mesh.o): requires dynamic R_X86_64_PC32 reloc against 'tessMeshAddEdgeVertex' which may overflow at runtime; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld.gold: error: /home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a(priorityq.o): requires dynamic R_X86_64_PC32 reloc against 'pqHeapNewPriorityQ' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
/home/cuinjune/Desktop/of_v0.10.0_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:403: recipe for target 'bin/ofelia.pd_linux' failed

What should I do to fix these errors?


#2

does ubuntu 16.04 have gcc6? i would say it was still 5 no? in that case you need OF gcc5 not 6


#3

I installed gcc6 so it uses gcc6.

I’m trying to build a shared a library using OF 0.10.0.

How do I compile OF libs with -fPIC? Is there any instructions or precompiled binary files?

I also added PLATFORM_CFLAGS += -fPIC to OF/libs/openFrameworksCompiled/project/linux64/config.linux64.default.mk file.


#4

even if you installed gcc6 it’s probably using the flags for gcc5, try downloading the gcc5 version. enabling -fPIC to compile OF wouldn’t make any difference cause you are getting the errors in the external dependencies which is what changes from the gcc5 to the gcc6 download