Native C "Hello World" working in emulator

Discuss porting Android to any device.

Native C "Hello World" working in emulator

Postby plusminus » Sat Nov 17, 2007 12:23 pm

Follow these instructions to run (a simple) native C-App on the Android-Emulator.
(As I'm not that familiar with C, I cannot test if it really works.)
:arrow: Somewhone who can approve that :?:

1) Create your hello world program:

Syntax: [ Download ] [ Hide ]
Using c Syntax Highlighting
  1. #include
  2.  
  3. int main(int argc, char** argv) {
  4.    printf("Hello World - says anddev.orgn");
  5.    return 0;
  6. }
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


2) Compile with an arm cross-compiler toolchain. I used a toolchain I
built with gentoo's crossdev tool, but there are lots out there.
Assuming your c file is hi.c and your cross compiler is called armv6-
vfp-linux-gnueabi-gcc, you can compile using:

armv6-vfp-linux-gnueabi-gcc hi.c -o hi -static

Note the -static. I've not figured out the version of libc etc or the
ABI used yet, so for now, link applications statically.


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby dave » Sat Nov 01, 2008 1:53 pm

Very cool.... Gives me a ray of hope (I'm not very good with Java but C and C++ can work with my eyes closed!)
dave
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Oct 31, 2008 5:29 pm
Location: Kent

Postby dave » Sat Nov 01, 2008 1:54 pm

Very cool.... Gives me a ray of hope (I'm not very good with Java but C and C++ can work with my eyes closed!)
dave
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Oct 31, 2008 5:29 pm
Location: Kent

Top

Return to Porting Android

Who is online

Users browsing this forum: No registered users and 4 guests