Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uclinux - link with libc.so.0 library

I'm trying to compile "hello world" C application for embedded system with ARM processor running uClinux. I'm using this toolchain

When I compiled C application with -static compilation flag the application is working fine. When I removed -static flag - I got an error: can't load library 'libc.so.6'

libc.so.6 does not exists on the target, into /lib folder on the target device the symbolic link libc.so.0 points to libuClibc-0.9.33.2.so

How can I "tell" compiler to link with libc.so.0?

like image 779
Dima Avatar asked Oct 26 '25 22:10

Dima


1 Answers

I had a similar problem when cross-compiling a simple helloworld from an openwrt toolchain (using uClibc, target IPQ4028) to my router Gl-iNet-B1300. After compiling successfully, I scp the file to the router and when trying to execute this error came up:

    root@GL-B1300:~# ./helloworld
    /root/helloworld: can't load library 'libc.so.0'

When I run 'ls -la | grep libc.so.' on /lib/, this came up:

    libc.so.1 -> libuClibc-1.0.14.so

So as libc.so.0 wasn't there, I just created a link in /lib/

    lib/# ln -s libc.so.1 libc.so.0

Running again 'ls -la | grep libc.so.':

    libc.so.0 -> libc.so.1
    libc.so.1 -> libuClibc-1.0.14.so

And then, executing the file:

    root@GL-B1300:~# ./helloworld
    Hell! O' world, why won't my code compile?
    The value of pi is 3.141593

I guess the real problem here is that the toolchain I'm using is not the right one for the router firmware.

like image 66
Mauro Avatar answered Oct 29 '25 20:10

Mauro