Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 09-05-2011, 12:11 AM   #1
ninjageckoattack
Junior Member
ninjageckoattack began at the beginning.
 
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?
ninjageckoattack is offline   Reply With Quote
Old 09-05-2011, 07:02 AM   #2
TJW
Enthusiast
TJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipediaTJW knows more than wikipedia
 
Posts: 27
Karma: 47504
Join Date: Aug 2011
Device: Kindle DXG
use glibc 2.5 toolchain instead.
TJW is offline   Reply With Quote
Old 09-05-2011, 10:25 AM   #3
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,962
Karma: 4501011
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
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.
NiLuJe is offline   Reply With Quote
Old 09-07-2011, 05:03 PM   #4
ninjageckoattack
Junior Member
ninjageckoattack began at the beginning.
 
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.
ninjageckoattack is offline   Reply With Quote
Old 09-07-2011, 09:27 PM   #5
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,962
Karma: 4501011
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
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.
NiLuJe is offline   Reply With Quote
Old 09-07-2011, 11:29 PM   #6
ninjageckoattack
Junior Member
ninjageckoattack began at the beginning.
 
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
However, in my version, it gives me the lines:
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.
Why would this code be using glibc 2.7 when the function is clearly available in glibc 2.4?
ninjageckoattack is offline   Reply With Quote
Old 09-08-2011, 12:39 AM   #7
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,962
Karma: 4501011
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
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.
NiLuJe is offline   Reply With Quote
Old 09-08-2011, 08:16 AM   #8
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,131
Karma: 2115387
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.
hawhill is offline   Reply With Quote
Old 09-08-2011, 11:55 AM   #9
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 4,962
Karma: 4501011
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2
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 .
NiLuJe is offline   Reply With Quote
Old 09-08-2011, 04:09 PM   #10
ninjageckoattack
Junior Member
ninjageckoattack began at the beginning.
 
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.
ninjageckoattack is offline   Reply With Quote
Old 09-09-2011, 12:14 PM   #11
kindle3zeng
Enthusiast
kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.kindle3zeng once ate a cherry pie in a record 7 seconds.
 
Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
Quote:
Originally Posted by ninjageckoattack View Post
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.
If you're using Linux, you can try this one, I built it on Ubuntu 10.10. I used it to compile some large software(VIM, Python, etc.), and I didn't encounter any problem yet:
https://rapidshare.com/files/3271781...cc4.2.4.tar.gz
kindle3zeng is offline   Reply With Quote
Old 09-09-2011, 05:28 PM   #12
ninjageckoattack
Junior Member
ninjageckoattack began at the beginning.
 
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.
ninjageckoattack is offline   Reply With Quote
Old 02-25-2012, 04:15 PM   #13
idoit
Plus
idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.
 
idoit's Avatar
 
Posts: 366
Karma: 262144
Join Date: Jan 2012
Location: Tehran, Iran - Halifax, Canada
Device: iPhone 5s
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).
idoit is offline   Reply With Quote
Old 02-25-2012, 04:29 PM   #14
Nyoxi
Connoisseur
Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.Nyoxi can really shake a tail feather.
 
Posts: 55
Karma: 116549
Join Date: Jan 2012
Device: Kindle Touch
Quote:
Originally Posted by cscat View Post
(ie. to run qemu ON Kindle).
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
Nyoxi is offline   Reply With Quote
Old 02-25-2012, 04:44 PM   #15
idoit
Plus
idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.idoit ought to be getting tired of karma fortunes by now.
 
idoit's Avatar
 
Posts: 366
Karma: 262144
Join Date: Jan 2012
Location: Tehran, Iran - Halifax, Canada
Device: iPhone 5s
Quote:
Originally Posted by Nyoxi View Post
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.
I'd like to just play around, eg. emulate DSL on my Kindle and etc. (with care, because I don't want to brick my Touch again!)

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!
idoit is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling the Linux Kernel for the Kindle yifanlu Kindle Developer's Corner 60 05-18-2014 08:47 AM
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


All times are GMT -4. The time now is 09:49 PM.


MobileRead.com is a privately owned, operated and funded community.