Question

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?

Was it helpful?

Solution 2

Seems like the toolchain you are using is built for glibc. But the target board has uClibc installed.
These two libraries are incompatible.
At runtime they are incompatible, and at compile-time they are incompatible.
You cannot "tell the compiler to use a different & incompatible library.
You need to obtain a toolchain that is built specifically for uClibc instead of glibc/eglibc.

The site gnuarm.com used to have some reliable toolchains, but that site is no more.

You could try and build your own toolchain using crosstool-NG, which is a lot easier than building the individual toolchain packages. Try the arm-unknown-linux-uclibcgnueabi configuration and customize it to your needs.

OTHER TIPS

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.

You should add the code "load XXX.lib" in your code if you remove -I. There are some differences between static and dynamic link which you can find in Google.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top