Tag Archives: development

Android

How to compile Android SDK samples

Recently I came across a Stackoverflow question about sample code in Android SDK.
The user was asking how to import code in an Eclipse project.

I’m not using Eclipse in my Android projects so I answered with command line instructions. My development environment is based on vim and bash.

My answer was a bit off topic, but can be useful to someone else.

Let’s presume you want to compile LunarLander sample.
You need to copy the directory recursively to a new path and work on it with the android command:
$ cp -r $ANDROID_SDK/samples/android-15/LunarLander .
$ android update project --path LunarLander/ --target 3 --subprojects
$ cd LunarLander/
$ ant debug install

You have to check the targets available to your system with the following command:
$ android list targets

References

iphone-gcc: compilare C/C++ su iPhone

Finalmente torna a funzionare gcc sul mio iPhone, stavolta con firmware 3.0.
Prerequisiti

  • connessione internet da iPhone
  • iPhone jailbroken

Procedura

  1. collegarsi via ssh al telefono
  2. scaricare ed installare fake-libgcc

    root # wget http://files.getdropbox.com/u/876743/fake-libgcc_1.0_iphoneos-arm.deb
    root # dpkg -i fake-libgcc_1.0_iphoneos-arm.deb

 

  • installare com.bigboss.20toolchain e libstdc++

    root # aptitude install com.bigboss.20toolchain libstdc++

 

Esempio: Hello world!
Questa è una verifica del funzionamento:

root # cat main.c
#include “/private/var/include/stdio.h”
int main(int argc, char** argv) {
printf(“Hello World!\n”);
  return 0;
}
root # gcc -Wall -I/private/var/include/ main.c
root # ./a.out
Killed
root # ldid -S a.out
root # ./a.out
Hello World!
root #