Google Groups Home
Help | Sign in
Developing C++ console applications for Android
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Aaron P. D'Souza  
View profile
(3 users)  More options Nov 14 2007, 1:40 pm
From: "Aaron P. D'Souza" <adso...@gmail.com>
Date: Wed, 14 Nov 2007 10:40:50 -0800
Local: Wed, Nov 14 2007 1:40 pm
Subject: Developing C++ console applications for Android
ANDROID OS TIPS

* to start emulator
  ./emulator -console

* to xfer a file to emulator; this is stored in emulator's
userdata.img file
  adb push <file> <dst file>

* to copy a file or a directory recursively to emulator
  adb push <source> <destination>

* to copy a file or a directory recursively from emulator
  adb pull <source> <destination>

* emulator can run native ARM Linux code.
  build your apps using GNU/ARM Linux toolchain and then run in
emulator.

* to get a shell on the emulator
  adb shell

* to run a console app on Android emulator
  adb shell <Linux command>

* to connect to emulator console for specific commands
  telnet localhost 5554/6/8

BUILDING AND RUNNING A NATIVE C APP ON ANDROID EMULATOR

References

Native C "Hello World" working in emulator
http://groups.google.com/group/android-developers/browse_thread/threa...

Native C Applications for Android
http://benno.id.au/blog/2007/11/13/android-native-apps

Steps
* download and install GNU/ARM Linux tool chain
  http://www.codesourcery.com/gnu_toolchains/arm/download.html

* create C/C++ code. see below for sample code.

* build app without dynamic libraries using GNU/ARM Linux toolchain
  ex. arm-none-linux-gnueabi-g++.exe -static -o hello HelloAndroid.cpp

* start emulator in Windows by double clicking on $SDK_ROOT/tools/
emulator.exe

* in a Windows Command window, use "adb" to xfer executable to
emulator disk
  adb push hello /system/sbin/hello

* make your app executable; do not use chmod ugo+x
  adb shell chmod 777 /system/sbin/hello

* run your app in a console on the emulator
  adb shell
  cd /system/sbin/
  hello

EXAMPLE HELLO WORLD CODE
//
// HelloAndroid.cpp
//
//

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

class MyName
{
  public:
    void getname( void );
    void sayhello( void );

  private:
    char name[ 255 ];

};

void MyName::getname( void )
{
  cout << "What is your name? ";
  cin >> name;

}

void MyName::sayhello( void )
{
  cout << "Welcome " << name << " to the world of Android" << endl;

}

MyName name;

int main( int argc, char *argv[] )
{
  name.getname();
  name.sayhello();
  return 0;


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gaz  
View profile
(1 user)  More options Nov 14 2007, 1:50 pm
From: gaz <billy00the00...@yahoo.com>
Date: Wed, 14 Nov 2007 18:50:19 -0000
Local: Wed, Nov 14 2007 1:50 pm
Subject: Re: Developing C++ console applications for Android
You know guys that doing this will prevent your application in being
an Android application, yes?
If you tie up your app to a certain CPU, it mean that XYZ manufacturer
producing an Android device with a MIPS CPU (or whatever other CPU)
will not be able to run your app.
If you want to be really Android (and not Android/ARM) compatible, you
better stick with Java and let the JIT to do its own job.

On Nov 14, 10:40 am, "Aaron P. D'Souza" <adso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Augusto  
View profile
(1 user)  More options Nov 14 2007, 2:02 pm
From: Augusto <augusto.sellh...@gmail.com>
Date: Wed, 14 Nov 2007 19:02:32 -0000
Local: Wed, Nov 14 2007 2:02 pm
Subject: Re: Developing C++ console applications for Android
Exactly.

I find it kind of amusing that there are people fascinated with
building console based C apps for a phone platform, talk about a waste
of time! :-)

You have a whole new application platform with all the right
abstractions, a nice looking UI toolkit and access to 3D apps via
OpenGL and you're going to play with building a command line console
app? LOL!

On Nov 14, 1:50 pm, gaz <billy00the00...@yahoo.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gaz  
View profile
(1 user)  More options Nov 14 2007, 2:07 pm
From: gaz <billy00the00...@yahoo.com>
Date: Wed, 14 Nov 2007 19:07:45 -0000
Local: Wed, Nov 14 2007 2:07 pm
Subject: Re: Developing C++ console applications for Android
Writing native apps may be even cool, but defies the role of the
Android platform, sicne it moves portability down to the CPU layer.
At that point it becomes an HW platform instead of a SW one.

On Nov 14, 11:02 am, Augusto <augusto.sellh...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Slava Pestov  
View profile
(2 users)  More options Nov 14 2007, 2:14 pm
From: Slava Pestov <sl...@jedit.org>
Date: Wed, 14 Nov 2007 14:14:51 -0500
Local: Wed, Nov 14 2007 2:14 pm
Subject: Re: Developing C++ console applications for Android
Console applications are the first step. OpenGL is just a C library,  
calling into that should be easy once you get your console apps working.

Remember that not everybody wants to write their programs in Java.  
Some people want to write in other languages (not just C and C++) and  
many languages have VMs/runtimes implemented in C.

You should not be so rude to people such as Aaron P. D'Souza who are  
doing useful research here. Having a robust native toolchain for  
Android will benefit everybody, and it certainly is not a "waste of  
time".

Slava

On 14-Nov-07, at 2:02 PM, Augusto wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Slava Pestov  
View profile
(1 user)  More options Nov 14 2007, 2:16 pm
From: Slava Pestov <sl...@jedit.org>
Date: Wed, 14 Nov 2007 14:16:11 -0500
Local: Wed, Nov 14 2007 2:16 pm
Subject: Re: Developing C++ console applications for Android

On 14-Nov-07, at 2:07 PM, gaz wrote:

> Writing native apps may be even cool, but defies the role of the
> Android platform, sicne it moves portability down to the CPU layer.
> At that point it becomes an HW platform instead of a SW one.

Even if both Android/ARM and Android/PPC devices take off in the  
marketplace (that's a big if; Android itself may flop) people who  
wish to ship native applications can certainly just compile binaries  
for both architectures.

Slava


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Augusto  
View profile
(1 user)  More options Nov 14 2007, 2:21 pm
From: Augusto <augusto.sellh...@gmail.com>
Date: Wed, 14 Nov 2007 19:21:12 -0000
Local: Wed, Nov 14 2007 2:21 pm
Subject: Re: Developing C++ console applications for Android
Slava;

You are correct. It came out wrong, didn't mean to insult anybody.
Experimentation is great, I guess I was just having a reflex reaction
to the countless "why did Google not provide a native SDK" posts.
Sorry about that, Aaron, I apologize if I insulted you.

Hey I'm getting a kick just playing around in the shell, so I can see
some of the value to this. Hopefully people won't forget thought that
the main point of something like this is dealing with the higher level
constructs and application platform though.

On Nov 14, 2:14 pm, Slava Pestov <sl...@jedit.org> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gaz  
View profile
(1 user)  More options Nov 14 2007, 2:27 pm
From: gaz <billy00the00...@yahoo.com>
Date: Wed, 14 Nov 2007 19:27:06 -0000
Local: Wed, Nov 14 2007 2:27 pm
Subject: Re: Developing C++ console applications for Android
You seems to forget the fact that Android does *not* define any ABI
whatsoever from a CPU POV. And rightly so.
There is no lower layer Androind standard, besides the one exposed to
device manufacturers, that states that in order for them to be Android-
compatible, they have to be able to run Linux of their HW platform.
Going towards native apps defies the unification intent of Android.
Java with a half decent JITC, can be really performing. And this comes
from a core C developer, developing JITC solutions.

On Nov 14, 11:16 am, Slava Pestov <sl...@jedit.org> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Slava Pestov  
View profile
(1 user)  More options Nov 14 2007, 2:28 pm
From: Slava Pestov <sl...@jedit.org>
Date: Wed, 14 Nov 2007 14:28:56 -0500
Local: Wed, Nov 14 2007 2:28 pm
Subject: Re: Developing C++ console applications for Android
Right. I don't think anybody is looking to deliver end-user console  
applications for mobile phones. That would be really silly. The point  
is that having a native SDK really opens up a number of opportunities  
in terms of what you can do your device.

Personally I'm interested in porting my Factor language to Android,  
and using Factor to develop mobile applications. Factor already has  
an ARM compiler backend and runs on Windows Mobile. So "porting" in  
this case means first getting it working with Android's toolchain as  
a Linux/ARM as a console application, and then writing bindings to  
Android's C and Java libraries (we have a JNI bridge) and actually  
properly integrating with the platform.

Slava

On 14-Nov-07, at 2:21 PM, Augusto wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings pag