简体   繁体   中英

Hello World Android Program

I just built my goldfish android kernel. I wrote a hello world program and compiled using arm-linux-gnueabi-gcc. I used adb push to put the executable in /data/local of the emulated kernel. I was able to ssh into the emulated kernel using adb shell. When I cd into /data/local and ls the directory, I'm able to see the a.out which I had put using adb push. When I do #./a.out, I get the error ./a.out: not found.

Can some one help me on this.

I guess it's a missing library problem. I have met this problem before, my fix is below:

root@evab:~# ./a.out 
-sh: ./a.out: not found
root@evab:~# ls /lib /root
/lib:
libc.so.6

/root:
a.out
root@evab:~# 

Then check which shared library is needed by the application:

leo@leo-VirtualBox:/opt/nfs/root$ arm-linux-readelf a.out -a |grep lib
    [Requesting program interpreter: /lib/ld-linux.so.3]
    0x00000001 (NEEDED)                     Shared library: [libc.so.6]
... ...

By the output, we can confirm that the ld-linux.so.3 is missing, so copy ld-linux.so.3 to target filesystem /lib directory:

root@evab:~# ./a.out 
test
root@evab:~# ls /lib /root
/lib:
ld-linux.so.3 libc.so.6

/root:
a.out
root@evab:~# 

I added the -static option during compilation worked. arm-linux-gnueabi-gcc -static

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM