From://http://www.58player.com/blog-2534-94136.html
Recently want to play game production, so chose the current popular game engine cocos2d-x, although this thing has Android version, but the pro-test has a bug, and version update is particularly slow, immature, so choose Cocos2d-x Bar, using Eclipse for so many years, Very much like this compiler, sedentary, so I intend to continue to use eclipse as a development tool, good, gossip do not say, first talk about coco2d-x environment building, Due to the latest version of COCOS2D-X-3.2RC0, construction works slightly different, online tutorials are few, I intend to build their own process to share to everyone, reference.
My system is ubuntu14.04lts.
To prepare for the job, you need to download:
Jdk
Eclipse
ANROIDSDK (recommended to go to Google developer to download Google for Android developers to customize the Adt-bundle development tools, you can go to see)
Ndk
apache-ant-1.9.3
Above, please follow your own system of the number of self-download, I am 64-bit system.
The preparation has been worked out.
About the installation of the JDK environment I won't talk to you, this is simple, assuming the JDK has been built.
Settings for Environment variables:
Run ~/.BASHRC under terminal
At the end of the file, add
Android_sdk_root
Ndk_root
Ant_root
Ndk_module_root
Mine is:
#Cocos2d-X Export ANDROID_SDK_ROOT=/HOME/ROCKLI/ADT-BUNDLE/SDK export android_sdk_root_local=/home/rockli/ ADT-BUNDLE/SDK export path=${path}:/$ANDROID _sdk_root/tools/export path=${path}:/$ANDROID _sdk_root/platform-tools /export NDK_ROOT=/HOME/ROCKLI/NDK/ANDROID-NDK-R9D Export ndk_root_local=/home/rockli/ndk/android-ndk-r9d Export path=${path}:/$NDK _root Export ant_root=/home/rockli/apache-ant-1.9.3 export path=${path}:/$ANT _root/bin export NDK_ module_path=/home/rockli/cocos2d-x/cocos2d-x-3.2rc0/cocos2d-x-3.2rc0:/home/rockli/cocos2d-x/cocos2d-x-3.2rc0/ Cocos2d-x-3.2rc0/external:/home/rockli/cocos2d-x/cocos2d-x-3.2rc0/cocos2d-x-3.2rc0/cocos Export COCOS2DX_ROOT=/ Home/rockli/cocos2d-x/cocos2d-x-3.2rc0/cocos2d-x-3.2rc0
You can modify the root directory location of the file according to my configuration,
Get
After the environment variable is written into the BASHRC file, save the exit, and then don't forget the source and let them take effect.
First, the terminal enters the directory where the COCO2D-X-3.2RC0 is located,
The contents of the Cocos2d-x-3.2rc0 folder are as shown in.
Note: It's a good idea to install the basic tools that are compiled in a Linux environment first, by:
$ cd Cocos2d-x-3.2rc0/build $./install-deps-linux.sh
Two. Build Android project, run the setup.py as shown in the terminal:
./setup.py
Get:
Then follow his prompts for source HOME/ROCKLI/.BASHRC:
Three. Continue to the above directory, terminal run Cocos New project name-P package name-L CPP-D the directory where the project was built
Example: Cocos new Hellogame-p com.hellogamestudio.hellogame-l cpp-d/home/rockli
Four. Locate the hellogame in the/home/rockli directory, open the Get
The proj.android is what we want,
Under the terminal run Proj.android under the build_native.py to compile, the time is a bit long, wait for good.
Four. To import the project we just built into eclipse, this should be fine, the problem often occurs after the import
Note If you want to compile the project with Eclipse, you have to add the ndk_root environment variable in Eclipse, as follows: In the Eclipse toolbar,window->preferences->c/c++-> Build->builde variables->add-> writes the variable name Ndk_root, and the variable value is the directory where the NDK resides->apply->ok
and continue in this place select environment->add-> Add variable name: Ndk_root variable Value: ${ndk_root}->apply->ok
Import Project Proj.android:
An error occurs after you tick copy this to workspace
This time simply copy the classes file and Cocos2d folder under Hellogame to the workbench of Eclipse, as all projects will reference both packages.
After copy you will find that there are still errors, this time need to copy the src file in the cocos2d/cocos/platform/android/java/directory to the project directory, refresh, and found that there is no error.
Five. Right-click Hellogame, select Properties->c/c++->tool Chain editor-> Check out display compatible Toolchains only-> In the Currenttoolchain: drop-down box, select Android Gcc->apply->ok:
Finally, then class, run up. You will find that the Eclipse console is starting to run, which means you have succeeded.
Run the results I will not ha, live your success.
Article all hand dozen, very tired, reprint please indicate source http://blog.csdn.net/rockcode_li/article/details/37735837.
Use Eclipse to build cocos2d-x android environment under Ubuntu14.04lts