How to solve "error while loading shared libraries" when trying to run an arm binary with qemu-arm?

David picture David · Apr 23, 2013 · Viewed 36.9k times · Source

I'm running Linux Mint 14 with qemu, qemu-user, and the gnueabi toolchain installed. I compiled test.c with arm-linux-gnueabi-gcc test.c -o test.

When I try and run qemu-arm /usr/arm-linux-gnueabi/lib/ld-linux.so.3 test

I get an error saying: test: error while loading shared libraries: test: cannot open shared object file: No such file or directory. Running qemu-arm test, as I've previously tried, gives /lib/ld-linux.so.3: No such file or directory

However, the file does exist and is reachable.

$ stat /usr/arm-linux-gnueabi/lib/ld-linux.so.3
  File: `/usr/arm-linux-gnueabi/lib/ld-linux.so.3' -> `ld-2.15.so'
  Size: 10          Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d  Inode: 4083308     Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-04-22 16:19:48.090613901 -0700
Modify: 2012-09-21 08:31:29.000000000 -0700
Change: 2013-04-22 15:58:41.042542851 -0700
 Birth: -

Does anyone know how I can make qemu run an arm program without having to emulate an entire arm Linux kernel?

test.c is

#include <stdio.h>
int main() {
    printf("this had better work\n");
}

and file test is

test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0xf2e49db65394b77c77ee5b65b83c0cc9220cbfc0, not stripped

Answer

vivek_v picture vivek_v · Jun 20, 2013

you can run the example by providing a path to the arm-linux-gnueabi shared libs using the -L flag.

qemu-arm -L /usr/arm-linux-gnueabi/

also make sure the LD_LIBRARY_PATH is not set.

unset LD_LIBRARY_PATH