stetre/moonfltk

Can't compile on SparkyLinux.

Closed this issue · 8 comments

I have tried many different combinations of the install procedure e.g. getting fltk-dev, lua and moon-fltk from deb repository and/or compiling from source but whatever I do I consistently get this message when I try to 'make' moonfltk:

....many lines deleted.... /usr/bin/ld: /usr/local/lib/libfltk.a(Fl_File_Chooser2.o): relocation R_X86_64_PC32 against symbol _ZN15Fl_File_Chooser19add_fas_labelE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libfltk.a(fl_arci.o): relocation R_X86_64_PC32 against symbol `fl_gc' can not be used when making a object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[1]: [Makefile:162: moonfltk] Error 1 (ignored)

make[1]: Leaving directory '/home/jon/moonfltk/src'`

Any clues very much appreciated since I am really stuck. It worked out-of-the box on Lubuntu a few weeks, but the OS kept crashing, so I switched to Sparky which is faster and crashes less, but has its own issues ;-0

I have been through the command history I used for the Lubuntu install, without success so far.

Try changing -fpic to -fPIC in /src/Makefile at line 87 .

Forget mmy last comment. I just noticed from your error message that the linker is attempting to link against the FLTK static library (libfltk.a). Are you sure the FLTK shared objects (.so) are installed on your system?

Hello, yes, the .so files are there. I managed to sort it out with a bodge. I renamed the files:
/usr/local/lib/libfltk_gl.a
/usr/local/lib/libfltk_images.a
/usr/local/lib/libfltk.a
with a different extension so that they are ignored during linking (I hope) and the makefile ran OK, apparently. I renamed them back to '.a' afterwards for luck. My lua scripts run with moonfltk fine now.

Thanks for helping - happy to try a better solution.

Are the .so files in a different directory? As far as I know, the linker should choose the .so over the .a if it finds both.

Ah, ok. If that's the case, creating soft links to the .so files in /usr/local/lib should fix the issue.

Great, thanks. I must have got things in a twist when I installed fltk because I have since scrubbed everything (including removing the '.a' files in /usr/local/lib/ and the fltk-config binary), reinstalled fltk-dev from the repo and its all fine now. Now there are no '.a' files in /usr/local/lib/ after the re-install, so I do not know where they came from originally. For some reason the old fltk-config was making the linker use them instead of the files in /usr/lib/x86_64-linux-gnu/ where the '.a' and '.so' files now happily coexist.