How to run c program in Android4.4.2 wandboard?

Discuss Android on the Wandboard, as well as app development for or on the Wandboard.

How to run c program in Android4.4.2 wandboard?

Postby khiremandar » Thu Nov 06, 2014 3:06 pm

I want to understand how to compile kernel for Android 4.4.2 which in kernel_imx folder.
For verification of compilation steps i try to compile simple program with arm compiler.
I write demo.c as follows:-
Code: Select all
/* Hello World program */
void main()
    printf("Hello World \n");

After i compile this program..
Code: Select all
arm-linux-gnueabi-gcc /hello_c/demo.c

i found 'a.out' genrated in hello_c folder.
I copy it into 'data' partition in sd card which has installed Android4.4.2 precompiled image.
When i run wandboard & by minicom i try to run following command:-
Code: Select all
127|root@wandboard:/data # sh a.out 

I got following result:-
Code: Select all
�4�4' unexpected
Minicom2.71|root@wandboard:/data # Minicom2.7

I doesnt understand what i make mistake?

In Yocto project people do same thing for cross verify can we compile kernel properly before actually compile whole kernel.
when i check 'ar' in terminal i found
Code: Select all
root@abc:# ar
ar                                 arm-linux-gnueabi-size             arm-poky-linux-gnueabi-ar
arch                               arm-linux-gnueabi-strings          arm-poky-linux-gnueabi-as
arecord                            arm-linux-gnueabi-strip            arm-poky-linux-gnueabi-c++filt
arecordmidi                        arm-none-eabi-addr2line            arm-poky-linux-gnueabi-cpp
arm2hpdl                           arm-none-eabi-ar                   arm-poky-linux-gnueabi-elfedit
arm-linux-gnueabi-addr2line        arm-none-eabi-as                   arm-poky-linux-gnueabi-g++
arm-linux-gnueabi-ar               arm-none-eabi-c++                  arm-poky-linux-gnueabi-gcc
arm-linux-gnueabi-as               arm-none-eabi-c++filt              arm-poky-linux-gnueabi-gcc-ar
arm-linux-gnueabi-c++filt          arm-none-eabi-cpp                  arm-poky-linux-gnueabi-gcc-nm
arm-linux-gnueabi-cpp              arm-none-eabi-elfedit              arm-poky-linux-gnueabi-gcc-ranlib
arm-linux-gnueabi-cpp-4.7          arm-none-eabi-g++                  arm-poky-linux-gnueabi-gcov
arm-linux-gnueabi-dwp              arm-none-eabi-gcc                  arm-poky-linux-gnueabi-gdb
arm-linux-gnueabi-elfedit          arm-none-eabi-gcc-4.8.2            arm-poky-linux-gnueabi-gprof
arm-linux-gnueabi-gcc              arm-none-eabi-gcc-ar               arm-poky-linux-gnueabi-ld
arm-linux-gnueabi-gcc-4.7          arm-none-eabi-gcc-nm               arm-poky-linux-gnueabi-ld.bfd
arm-linux-gnueabi-gcc-ar-4.7       arm-none-eabi-gcc-ranlib           arm-poky-linux-gnueabi-nm
arm-linux-gnueabi-gcc-nm-4.7       arm-none-eabi-gcov                 arm-poky-linux-gnueabi-objcopy
arm-linux-gnueabi-gcc-ranlib-4.7   arm-none-eabi-gprof                arm-poky-linux-gnueabi-objdump
arm-linux-gnueabi-gcov             arm-none-eabi-ld                   arm-poky-linux-gnueabi-ranlib
arm-linux-gnueabi-gcov-4.7         arm-none-eabi-ld.bfd               arm-poky-linux-gnueabi-readelf
arm-linux-gnueabi-gprof            arm-none-eabi-nm                   arm-poky-linux-gnueabi-size
arm-linux-gnueabi-ld               arm-none-eabi-objcopy              arm-poky-linux-gnueabi-strings
arm-linux-gnueabi-ld.bfd           arm-none-eabi-objdump              arm-poky-linux-gnueabi-strip          arm-none-eabi-ranlib               arp
arm-linux-gnueabi-nm               arm-none-eabi-readelf              arpd
arm-linux-gnueabi-objcopy          arm-none-eabi-size                 arping
arm-linux-gnueabi-objdump          arm-none-eabi-strings              ar.single
arm-linux-gnueabi-ranlib           arm-none-eabi-strip               
arm-linux-gnueabi-readelf          arm-poky-linux-gnueabi-addr2line   

So as per my knowladge toolchain is set for arm?
So now question is how to run c program in wandboard which compiled by arm compiler which used for Android compilation?
Posts: 86
Joined: Wed Sep 03, 2014 11:38 am

Re: How to run c program in Android4.4.2 wandboard?

Postby Richard » Fri Nov 07, 2014 2:06 am

Hello, khiremandar:

Android uses bionic C Library rather than standard C library.
Try to build this program as "static":
Code: Select all
arm-linux-gnueabi-gcc -static /hello_c/demo.c


Site Admin
Posts: 133
Joined: Tue Dec 17, 2013 6:57 am

Re: How to run c program in Android4.4.2 wandboard?

Postby Ewalt106 » Mon May 08, 2017 10:26 am

there is rarely a person in the United States that does not Kitchen Reviewed leakage air back in, so utilize just covers that aren't harmed.
Posts: 2
Joined: Thu Apr 27, 2017 10:44 am

Return to Software - Android

Who is online

Users browsing this forum: No registered users and 4 guests