Can't compile ("relocation can not be used")
A fresh install of ubuntu 16.10, make, getting this:
g++ -o g13d -std=c++0x \
g13_main.o g13.o g13_log.o g13_fonts.o g13_lcd.o g13_stick.o g13_keys.o helper.o \
-lusb-1.0 -lboost_program_options \
-lboost_log \
-lboost_system -lpthread
/usr/bin/ld: g13.o: relocation R_X86_64_32 against symbol `_ZN5boost9parameter7keywordINS_3log11v2_mt_posix8keywords3tag8severityEE8instanceE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: g13_log.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: g13_fonts.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: g13_lcd.o: relocation R_X86_64_32 against symbol `_ZN5boost9parameter7keywordINS_3log11v2_mt_posix8keywords3tag8severityEE8instanceE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: g13_stick.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: g13_keys.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: helper.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:33: recipe for target 'g13d' failed
make: *** [g13d] Error 1
Compiled on Mint just fine before, not sure what I am doing wrong...
My solution for a very similar issue in Kubuntu 18.04 was to use the -no-pie option in the g++ statement in the Makefile.
The -no-pie creates a "regular" (position dependent) executable. The thing is: at least in Ubuntu >= 17.04 (and probably in derivatives like Mint), GCC produces position-independent executables (PIE) by default, whether programs or shared libraries. Same as Debian 9. This has to do with preventing certain security attacks (see https://en.wikipedia.org/wiki/Position-independent_code). With -no-pie we are saying "we don't want that", which while is not the best solution, is one that gets you ready to work very quick (alternative is more cumbersome).
So, in steps:
- Edit the Makefile, and change the line that starts with:
g++ -o g13d -std=c++0x \by adding-no-pieso that it now looks like this:g++ -o g13d -std=c++0x -no-pie \Save the file. - In the same sources directory (i.e., where Makefile is), delete (or move to somewhere else) the existing
g13dfile. Then runmake clean. - In the same sources directory, run
make. The compiling should now be successful without errors and produce your brand new g13d binary.
Request to the developers: Could you please add at least a note in the README or elsewhere about this issue? Now with the upgrades to Ubuntu 18.04, many people will get his by this issue. It is not trivial, because when one upgrades, the only thing that happens is that g13d dies without any visible cause. Unless one tries to compile, it can be very difficult to figure it out.
Thanks a lot for this excellent project! I use this driver a lot: it allows me to run my G13 to control Krita on Linux, with my own configurations files.