[uClibc]Dynamic libuClibc.so woes

Erik Andersen andersen at lineo.com
Wed Mar 7 22:55:30 UTC 2001


On Wed Mar 07, 2001 at 02:07:31PM -0800, John Lombardo wrote:
> Manuel,
> 
> Thanks for the tip, it finally worked for me.
> 
> I applied all the patches, and your patch too.  Did the make clean and the
> "make ARCH=i386 CC=/path/to/gcc-uClibc-i386" and it worked fine.  At just
> over 22k, it's really tiny too -- which I like a lot.
> 
> It still bothers me that I can't figure out how to use the ld-linux.so from
> glibc.  Like I said before, I tried the ld-linux.so.2, but that didn't work.
> Has anyone gotten this to work?  If so, which version of glibc?  Any special
> compile options?  Should I be using ld-linux-so.2, or is there a .1?  Should
> I just rename the .2 .1 or something stupid like that?
> 
> Regards,
> John

I'm assuming you are on x86 here.  So lets just compile something...

[andersen at slag andersen]$ cd CVS/uClibc
[andersen at slag uClibc]$ cp Config.x86 Config
[andersen at slag uClibc]$ make
[-----------compiling snipped-----------]
No missing symbols found.
gcc -g -s -nostdlib -Wl,-warn-common -shared -o libuClibc.so.1 -Wl,-soname,libuClibc.so.1 tmp/*.o

Finally finished compiling...

[andersen at slag uClibc]$ sudo make install
+ mv -f /lib/libuClibc.so.1 /lib/libuClibc.so.1.old
+ rm -f /lib/libuClibc.so.1.old
+ cp libuClibc.so.1 /lib
+ chmod 644 /lib/libuClibc.so.1
+ chown -R root.root /lib/libuClibc.so.1
+ rm -f /lib/libuClibc.so
+ ln -s /lib/libuClibc.so.1 /lib/libuClibc.so
+ ldconfig
[andersen at slag uClibc]$ cd test/silly/
[andersen at slag silly]$ cat hello.c
#include<stdio.h>
#include <stdlib.h>

int main(void)
{
    printf("hello world\n");
    exit(42);
}
[andersen at slag silly]$ ../../extra/gcc-uClibc/gcc-uClibc-i386 -Wall -Os hello.c -o hello
[andersen at slag silly]$ ldd ./hello
        libuClibc.so.1 => /lib/libuClibc.so.1 (0x4000c000)
        ld-linux.so.1 => /lib/ld-linux.so.1 (0x40039000)
[andersen at slag silly]$ ls -sh ./hello
4.0k ./hello*
[andersen at slag silly]$ ./hello
hello world


So there you have it.  An app compiled using a shared uClibc.  As can be seen
by running 'ldd' it is linked automagicaly with the glibc shared library
loader, so you don't need to do anything else to make it work.  If this were
busybox and you wanted to use busybox as your init process, then you would just
need to make sure you have /lib/libuClibc.so.1 and /lib/ld-linux.so.1 installed
on your target (along with some /dev entries and a kernel) and all should work
just fine.  I done exactly this and it worked for me...

 -Erik

--
Erik B. Andersen   email:  andersen at lineo.com
--This message was written using 73% post-consumer electrons--





More information about the uClibc mailing list