« Previous -
Version 17/23
(diff) -
Next » -
Current version
Minggo Zhang, 2011-09-26 22:50
How to run HelloWorld and tests on linux¶
This document will describe how to run HelloWorld and tests on linux.
1. Set up environment¶
1.1 get cocos2d-x source code¶
a) get latest code from git, it is not stable
b) get released version, it is stable
1.2. install android sdk¶
Refer the link to install android sdk http://developer.android.com/sdk/index.html
Use this appoach to install jdk
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update sudo apt-get install sun-java6-jdk
1.3. install cdt for eclipse to compile c/c++ codes in eclipse¶
Help -> Install New Software... -> Add...
The link of cdt is http://download.eclipse.org/tools/cdt/releases/helios.
1.4. install ndk¶
You can download ndk here http://developer.android.com/sdk/ndk/index.html
Because we use ndk standalone toolchain to build android programe, so we should do some work
# create a "customized" toolchain installation $NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=<your path> # add the environment variable in /etc/profile, because eclispe should use it export PATH="$PATH:<your path>"
NDK is the root of your ndk, you should change <your path> to your own path.
More information of ndk standalone toolchain, please refer http://www.srombauts.fr/android-ndk-r5b/docs/STANDALONE-TOOLCHAIN.html
1.5. install needed libs¶
sudo apt-get install libgl1-mesa-dev libglfw-dev freeglut3-dev libzip-dev
If you meet problem as me, maybe you should run the command before installing the libs
sudo apt-get -f
2. Run with makefile¶
It is simple to run with makefile
cd $HELLOWORLD/linux/ make ./HelloWorld
HELLOWORLD is the root of helloworld, in my environment it is /home/zhangxm/cocos2d-x/HelloWorld.
You can run tests and HelloLua in the same way. It is simple, isn't it?
3. Run with eclipse¶
First, import existing projects: File -> Import...
Then select the directory of the root of cocos2d-x
- build
Right click the project of HelloWorld -> Build Project - run
Right click the project of HelloWorld -> Run as -> Local c/c++ Application
4. Run on android emulator¶
4.1 Build .so¶
1. Right click the project of HelloWorld -> Build Configurations -> Set Active -> AndroidDebug
2. Right click the project of cocos2dx-base -> Build Configurations -> Set Active -> AndroidDebug
3. Right click the project of CocosDenshion -> Build Configurations -> Set Active -> AndroidDebug
4. Right click the project of HelloWorld -> Build Project
The steps above are compiling libcocos2d.so libcocosdenshion.so and copy these .so into HelloWorld/android/libs/armeabi.
4.2 New android project and run¶
File -> New -> Project -> Android Project