Question

I have an embedded system running Linux Kernel 3.10 and Busybox.

If I cross compile (toolchain build by buildroot so its using uclibc) a program without the -static flag. It wont run.

-/bin/sh: helloworld: not found

If I compile my code with the -static flag. It will normally run and output HelloWorld

Whats going on here?

Was it helpful?

Solution 2

I found the answers.. I mad a simple mistake of not putting the uClibc libraries on my filesystem.

I know have the libraries there and I can run non static applications!

OTHER TIPS

Just an addition to above which clarifies if any body face same problem .. as i saw above question just now..

If you compile busybox with statically.Then no need to worry about shared library. But if you compiled busy box with dynamically then your toolchain plays important role in rootfs. here you need to copy libraries of toolchain to rootfs /lib folder .

what are the library need to be copied can be known just type following command.

strings _install/bin/busybox | grep ^lib

shows list library that should be kept in /lib of your rootfs.

This command says, “Get all the strings from the file, and only show the lines that begin with lib.” The program ldd can’t be used, because the program has been cross-compiled and won’t run on the development host. These files should be fetched from the sysroot directory of the toolchain. Most modern toolchains have been configured with a sysroot, which is a directory that contains the files from the toolchain likely to appear on a root file system of a system targeted by the toolchain. To check if your toolchain has sysroot support, try the following:

$ arm-linux-gcc -print-sysroot

/arm-unknown-linux-gnueabi/bin/arm-linux-gcc If this is a valid path, this is where the files should be copied from. If no path is displayed, use find to locate a sysroot directory in , or use find to look for libc.so:

$ find . -name libc.soAfter you’ve located libc and libm, create the (your rootfs)/lib directory and copy them there. The files are likely symlinks to other files, so be sure to gather them all. The next file to get is the dynamic loader, normally called ld-linux-, which also resides in the lib directory along with libc.so.*. Copy that to the /lib directory. Your system now has all the shared libraries and the loader, so BusyBox can run.`

The solution to this problem is to copy the uClibc libraries into the target file system that can be done bu following these steps:

1.The uClibc libraries are present in the folder "buildroot/output/target/lib/". 2.We have to copy all the files from this folder into the "/lib" folder of target filesystem. 3.The copy thing can be done by "scp" command. sudo scp -r PATH_TO_BUILDROOT/output/target/lib/* TARGET_USERNAME@TARGET_IP:/lib

After doing this all applications will run properly.

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