![]() |
#1 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
|
Cross compiling for the Kindle - wrong glibc version
I have been trying to set up a machine to cross-compile for the Kindle. I have been able to make a simple "Hello world" program and run it, but anything more complicated than that seems to fail.
For example, trying to compile the kindle terminal program works, but running it gives the error: "./myts.arm: /lib/libc.so.6: version `GLIBC_2.7' not found (required by ./myts.arm)" I am using scratchbox2 and CodeSourcery's arm-none-linux-gnueabi toolchain to compile it. I have tried copying the /lib and /usr/lib directories from my kindle to my computer and setting gcc's sysroot to their location, but that results in the error that crt1.o and crti.o cannot be found. How do I compile using the Kindle's version of these libraries? |
![]() |
![]() |
![]() |
#2 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27
Karma: 47524
Join Date: Aug 2011
Device: Kindle DXG
|
use glibc 2.5 toolchain instead.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Or, if the program you're trying to build doesn't really use newer glibc features, you can avoid pulling the whole set of GLIBC_2.7 symbols related to the fortify & stack smashing features of newer glibc/gcc couples by putting
-fno-stack-protector -U_FORTIFY_SOURCE in your CFLAGS. That won't help you if your program actually *wants* to use newer glibc features (depending on the feature in question, it might be easy enough to hack around it). readelf is your friend to check you're not pulling unwanted symbols ![]() (I'm using a GCC 4.5/Glibc 2.9 TC to build stuff for the hacks, for example, and I have yet to run into more trouble than a silly hack in coreutils to avoid ABI mismatches). Last edited by NiLuJe; 09-05-2011 at 10:29 AM. |
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
|
I tried putting those two commands in my CFLAGS, but it did not help the problem. In fact, running diff on the binaries with and without those flags showed that those flags do not change the output of the compiler at all.
|
![]() |
![]() |
![]() |
#5 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
That's assuming the stuff you're trying to build doesn't have an utterly broken buildsystem, and actually respects CFLAGS and stuff like that
![]() Anyway, readelf is your friend to pinpoint which symbol(s) are problematic. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
|
ok, so after taking a crash course in readelf, I have found out that sscanf is the function pulling GLIBC 2.7. I have a working version of the executable compiled by someone else to compare it to. In the working version, readelf gives the lines:
Code:
36: 0000902c 0 FUNC GLOBAL DEFAULT UND sscanf@GLIBC_2.4 (2) 427: 0000902c 0 FUNC GLOBAL DEFAULT UND sscanf@@GLIBC_2.4 Code:
13: 00008efc 0 FUNC GLOBAL DEFAULT UND __isoc99_sscanf@GLIBC_2.7 (4) 383: 00008efc 0 FUNC GLOBAL DEFAULT UND __isoc99_sscanf@@GLIBC_2. |
![]() |
![]() |
![]() |
#7 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Try adding -ansi to your CFLAGS. If it doesn't break anything, that'll make sure no c99 symbols get pulled.
EDIT: If you don't care about portability (in this case, it shouldn't matter, we know that our target system will always be Linux/glibc 2.5), -D_GNU_SOURCE is another way to workaround this (and is probably less likely to break stuff). That's what I usually do in the sscanf case, in fact. Last edited by NiLuJe; 09-08-2011 at 12:51 AM. |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
|
Depending on how much you intend to work with the toolchain, I'd strongly suggest using a glibc 2.5 based one. Otherwise, you'll always be chasing these kind of errors and it all sums up in a much bigger effort than just compiling a matching toolchain.
|
![]() |
![]() |
![]() |
#9 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
True. I only build a small amount of 'simple' stuff, and have some experience dealing with these kinds of issues, so it doesn't bother me much, but depending on what you intend to build, it might get pretty hairy
![]() |
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
|
Thank you for your help, I was able to compile the program and run it with the -D_GNU_SOURCE option. I have tried to just use a glibc 2.5 toolchain, but I don't know where/how to get one. I tried using the OSELAS.Toolchain, but compiling it always gave me some errors. Anyways, this worked.
|
![]() |
![]() |
![]() |
#11 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
|
Quote:
https://rapidshare.com/files/3271781...cc4.2.4.tar.gz |
|
![]() |
![]() |
![]() |
#12 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
|
OK, cool. I downloaded that toolchain, and got it working with scratchbox2. Interesting note: when you are running sb2-init, it is very important to give the full path to qemu or whatever you are using for cpu transparency. Pathetically enough, that was what gave me the most trouble.
|
![]() |
![]() |
![]() |
#13 |
hub
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 715
Karma: 2151032
Join Date: Jan 2012
Location: Iranian in Canada
Device: K3G, DXG, Kobo mini
|
Can someone provide me with a qemu on/for Armel please?
Note: I don't want qemu-system-arm as it is for a scenario where the target platform is ARM and not the host. (ie. to run qemu ON Kindle). |
![]() |
![]() |
![]() |
#14 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55
Karma: 124493
Join Date: Jan 2012
Device: Kindle Touch
|
May I be so bold as to ask what is the reason behind it? Just curious.
EDIT: Optware seems to have the qemu. You can use opkg/ipkg to install it (search the forum for that). It only supports i386, however. Last edited by Nyoxi; 02-25-2012 at 04:34 PM. Reason: i386 only |
![]() |
![]() |
![]() |
#15 | |
hub
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 715
Karma: 2151032
Join Date: Jan 2012
Location: Iranian in Canada
Device: K3G, DXG, Kobo mini
|
Quote:
I tried that qemu but reason for asking here was if anyone with a gcc in their Kindle has compiled qemu or not? That'll have support for more than just i386 I suppose! |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compiling the Linux Kernel for the Kindle | yifanlu | Kindle Developer's Corner | 82 | 12-12-2016 09:35 PM |
Wrong Version | HalfEmptyHero | Devices | 1 | 06-22-2011 10:55 AM |
Calibre Linux: Wrong version number | samy2 | Calibre | 9 | 06-19-2011 09:59 AM |
cross compiling links | dent | Kindle Developer's Corner | 1 | 02-07-2011 08:42 AM |
cross-compiling gstreamer for the kindle3 | dent | Kindle Developer's Corner | 9 | 02-04-2011 08:39 AM |