Tips in development of cocos2d-x project


Below contains some useful information gathered when I tried to solve problems happened in developing cocos2d-x related project for Android.


1. When you meet compile error with message "must override a superclass method"


Check the project's properties and verify that Java Compiler -> Compiler compliance level is set to1.6.



Posted by kevino
,
If you are very poor developer who cannot afford to buy any cheep ARM evaluation kit, then qemu arm version including Google android emulator is a very good tool to experiment any embedded sw stuffs.

Here some instruction to run a basic C application to print "hello" message on Android emulator are shown.
All information listed here are all taken from the following very useful link and I modified source a little bit to support Android serial console out. 


So I will explain my modifications only which comes from the different serial port configuation used to stdio between versatilepb and android goldfish.

#define GOLDFISH_TTY_PUT_CHAR (*(volatile unsigned int *)0xff002000)

/*
 * This does not append a newline
 */
static void putc(int c)
{
GOLDFISH_TTY_PUT_CHAR = c;

void print_uart0(const char *s) {
 while(*s != '\0') { /* Loop until end of string */
 putc(*s); /* Transmit char */
 s++; /* Next char */
 }
}

Full source code can be downloaded here and compiling it will generate test.bin. It can be compiled with google arm tool chain version 4.2.1 included in Android NDK and include that into current PATH list.
mkdir baremetal
cd baremetal
unzip ../baremetal.zip
./bd.sh

To test this bare metal app, 

export ANDROID_SDK_ROOT={path to android sdk}

emulator @fry -kernel ./test.bin










Posted by kevino
,
I do most jobs on Windows for convenience and it makes me to find a way to port some useful linux applications. Here I introduce how to compile okl4_android_3.0 and emulator application runnable on Windows. If you want linux version, then see original link. http://ertos.nicta.com.au/software/okl4htcdream/


Compile android_emulator-ok using MinGW ( Edit: Do not use this. This windows version seems to have problem in dynamic translation from ARM code to x86 ).

1. Download emulator source. android-emulator-ok.tar.gz
2. Unrar it to {emulator_path}.
3. Apply the patch. 
4. Before running build-emulator.sh to build emulator, an sdl package should be compiled but the sdl source included in the above tar file has a compile error with mingw so I recommend to find different way.
5. Download qemu package included android froyo version. http://android.git.kernel.org/?p=platform/external/qemu.git;a=summary
6. Untar qemu package to {qemu_path}
7. cd {qemu_path}/distrib/sdl-1.2.12
8. ./android-rebuild.sh --sdl-config=$LOCAL/bin/sdl-config
9. Now ready to compile emulator
10. cd {emulator_path}/qemu
11. ./android-rebuild.sh --sdl-config=$LOCAL/bin/sdl-config --install=$CURDIR/emulator


Compile qemu included in latest android version using MinGW.

2. build SDL first
cd /d/work/qemu/distrib/sdl-1.2.12
./android-configure --prefix=/d/work/local
make
make install

3. Download below patch and apply it.
4. Build qemu
cd /d/work/qemu
./android-configure.sh --sdl-config=/d/work/local/bin/sdl-config
make



Compile okl4-android_3.0 using cygwin

Build okl4_android-3.0 binary using cygwin. Because python lower version 2.6 is required to compile okl4 source tree without any compile error, we need to install cygwin with python version 2.5 and it could not be done in MinGW. Please correct me if I am wrong.

1. For successful compile, setup build environment.
2. Download android-ndk package
3. Install it somewhere
4. export PATH={ndk_root}/build\prebuilt\windows\arm-eabi-4.2.1\bin:$PATH
5. Download soruce : okl4-android-3.0.tar.bz2
6. cd {okl4_path}
7. tar xfvj okl4-android_3.0.tar.bz2
8. Download and apply the patch. 
9. cd okl4-android_3.0
10. tools/build.py machine=androidsim project=examples example=hello PYFREEZE=False TOOLCHAIN=gnu_arm_eabi_toolchain
11. The above command will generate image.elf file successfully but failed to generate image.boot file. I don't know about python and someone will help me what is wrong?



Running emulator with okl4 test app under MinGW

1. Create an avd file(here froyo) required to run android emulator
2. Run emulator with okl4 example
cd /d/work/
./qemu/objs/emulator.exe @cupcake -os-type okl4 -show-kernel -verbose -kernel ../images/image.boot.bin




Posted by kevino
,