http://sensen.blog.51cto.com/1645588/322057
ex. arm-none-linux-gnueabi-g++.exe -static -o hello HelloAndroid.cpp
$SDK_ROOT/tools/emulator.exe
adb push hello /system/sbin/hello
adb shell chmod 777 /system/sbin/hello
adb shell
cd /system/sbin/
hello
EXAMPLE HELLO WORLD CODE
//
// HelloAndroid.cpp
//
//
#include
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;
}
arm-none-linux-gnueabi-g++.exe -static -oandroid123 android123.cpp
adb shell cd /system/sbin/android123
即可
int main( int argc, char *argv[] )
{
name.getname();
name.sayhello();
return 0;
test.c
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<=10;i++)
{
for(j=0;j<=i;j++)
printf(”*”);
printf(”n”);
}
return 0;
}
//
// 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;
}