uClibc success/failures/stories anyone?

Ken Moffat ken at kenmoffat.uklinux.net
Fri Aug 23 15:13:53 PDT 2002


Static building with uClibc sorted! Posting here in case anybody else gets
similar problems in the future.

On Fri, 2 Aug 2002, Ken Moffat wrote:

> On Thu, 1 Aug 2002, Dan Eicher wrote:
> 
>  
> >     Ok, now I think I see what's happening. I think you don't have the 
> > right extra options compiled in to uClibc. I've seen linker errors on a 
> > few progs and would find I need to turn on C99 math or RPC and then it 
> > would compile just fine. I don't think this would really hurt your goal 
> > just turn on extra options since it wouldn't end up in your static 
> > binary if it wasn't needed, it would only take up a little more space on 
> > your host system.
> 
>  No problems on the options, I think I've got these in, but I'm still at
> the stage of playing with a test program - all it does is print the
> version of my jpeglib header file (I had this lying around!). It's simple
> enogh that it builds ok (dynamically) with more or less any uClibc Config
> options.
> 
> >     Another thing I've seen is the progs are picky on how you tell them 
> > to compile against uclibc. Some you change just CC=i386-uclinux-gcc in 
> > configure, others need it as a command line option and some need the 
> > full path /usr/i386-linux-uclibc/usr/bin/1386-uclibc-gcc. Iptables and 
> > fdisk needed "CC=/usr/i386-linux-uclibc/bin/cc make" so you have a few 
> > options. I usually try all of them until I find one that works. There 
> > probably is an easy way that I don't know about and I have yet to find a 
> > "uClibc for unemployed art majors howto" but what would be the challenge 
> > in that?
> 
>  Played with some options for a little while, but didn't manage a
> successful static link. I'm now moving into pre-vacation-panic mode - I'll
> try and play a bit more, but I've got a lot of more urgent things to do by
> Sunday night!
> 

 Three steps to success:

1. Put the options in as in Dan's previous posting.

2. Build with HAVE_SHARED = true 
- this will let you build shared or static, I cannot get it to link
programs if it is built with this set to false.

3. After creating the object file for the program, 
 make LDFLAGS=-static progname 
- of course, if you use a Makefile you'll want $(LDFLAGS) in it.

Actually, I thought I was using a Makefile, but it got left behind when I
moved the files into a separate directory. I guess that my earlier
attempt to pass LDFLAGS on the command line for compile-and-link must have
had a syntax error.

 Just for the record, here are the stats on a one-line program that prints
out the version of the jpeg library (to test the header files could be
included, I forget why). gcc-2.95.3, glibc-2.2.4, dietlibc-0.17,
uClibc-0.9.12, no CFLAGS for any of them, host's architecture (gcc) i586.

  text    data     bss     dec     hex filename
  5422      64      16    5502    157e testinc.diet # static, dietlibc
346253   10804    3972  361029   58245 testinc.static # static, glibc
   769     260       4    1033     409 testinc.std # shared, glibc
   454     156       0     610     262 testinc.uclibc.shared
 12704     956     712   14372    3824 testinc.uclibc.static 

 Note that dietlibc is a lot smaller, but it can't build bash-2.05a.

 I'll definitely be giving chapter 5 a go some time to see how far I can
get like this. From what Dan said earlier, I'll probably need to start
altering some of the Makefiles. I'll also have fun with libraries by the
look of it - it can't find -lcurses to link bash (works ok with regular
gcc). I feel a learning experience coming on.

Ken 

-- 
 Out of the darkness a voice spake unto me, saying "smile, things could be
worse". So I smiled, and lo, things became worse.



-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list