Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile ("relocation can not be used") #29

Open
kar opened this issue Jan 21, 2017 · 2 comments
Open

Can't compile ("relocation can not be used") #29

kar opened this issue Jan 21, 2017 · 2 comments

Comments

@kar
Copy link

kar commented Jan 21, 2017

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...

@ocumo
Copy link

ocumo commented Jun 21, 2018

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:

  1. Edit the Makefile, and change the line that starts with:
    g++ -o g13d -std=c++0x \
    by adding -no-pie so that it now looks like this:
    g++ -o g13d -std=c++0x -no-pie \
    Save the file.
  2. In the same sources directory (i.e., where Makefile is), delete (or move to somewhere else) the existing g13d file. Then run make clean.
  3. In the same sources directory, run make.
    The compiling should now be successful without errors and produce your brand new g13d binary.

@ocumo
Copy link

ocumo commented Jun 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants