Eclipse Development COCOS2DX 3.2 Environment: Android c\c++ Environment Setup (NDK r9d)

Source: Internet
Author: User

These days have time, ponder cocos2dx. Cocos2d family is actually very large, there are cocos2d-android this can be directly in the Java language to develop, but cocos2d-android data relatively few, and seems to be a few years ago. Comparison or COCOS2DX is more popular, there can be cross-platform, and since it is necessary to learn the C + + learning.

This period of time has been used to the idea, do not want to change back, but the search found that the idea can not do C + + development. Domestic is a company has developed a idea of the Cocos plug-in, but in fact is cocos2dx-js, as if the latest version of the Cocos2dx-android added. The plug-in I simply use a bit, very convenient, interested can check it out for themselves.

Since idea can't be used, you have to switch back to eclipse. The first is to configure Eclipse's c\c++ environment.

Prepare as follows:

1, JDK7 currently use this version of the

2, Adt-bundle-windows-x86-20140702.zip This is the official Google Android collection version of Eclipse, which already contains ANDROIDSDK and ADT, CDT and other plugins, very convenient. There are many web disk downloads online

3. android-ndk-r9d COCOS2DX 3.2 This version must be used because of the reason for c++11. In addition, the R7 version of the NDK will no longer need to cygwin. Because of the domestic Google more laborious, and found on the internet a lot did not find good download, so the wall to download a put in the network disk. Http://pan.baidu.com/s/1qW0RJjQ


The first step:

Install JDK7, configure the environment, this online has a lot of, do not elaborate.


Step Two:

Decompression Adt-bundle-windows-x86-20140702.zip, the inside has been configured well, after decompression can be used.


Step Three:

Install the NDK, and you can unzip it directly. It is best to configure the NDK directory on the system variable path.


Fourth Step:

Create a test project.

Create an Android project, make a new JNI folder, and copy the files from the Android-ndk-r9d\samples\hello-jni\jni to the past. Also copy the android-ndk-r9d\samples\hello-jni\src\****\ under Hellojni.java to the project's src\ package name \.

Note Here to modify the package name of Hellojni.java and Hello-jni.c method name according to the project package name, otherwise it will be an error!

For example: Test Project package name Com.example.ndktest, you need to change the Hello-jni.c method name Java_com_example_hellojni_hellojni_stringfromjni () to java_com _example_ndktest_hellojni_stringfromjni ().


Fifth Step:

Configure Builder.

Since the NDK R7 version comes with Toolchains and no longer requires Cygwin, it is possible to compile files directly using the Ndk-build.dat in the NDK directory. So before we run we'll build the NDK by configuring a builder.

Here is the reference to another microblogging, the original address http://www.it165.net/pro/html/201404/11620.html, because said in detail, I stole a lazy.

Click Project->properties->builders->new to create a new builder. Click program,ok! on the dialog box that pops up Four of the following:

(Figure IV)
In the popup dialog "Edit Configuration", configure Tab "Main":
The path in the location where the nkd-build.cmd is required (under the NDK installation directory).
Working diretcoty need to fill in the testndk of the project root directory.
Five is shown below:

(Figure V)
The Configuration tab, "Refresh", is shown in six:
Tick "Refresh Resources upon completion",
Tick "The entire workspace",
Tick "recuresively include sub-folders".

(Figure VI)
The Configuration tab, "Build options," is shown in seven:
Tick "After a" and "clean",
Tick "During Manual builds",
Tick "During Auto Builds",
Tick "Specify working set of relevant resources".
Click "Specify Resources ..." to check the "JNI" directory of the TESTNDK project, finish!

Save Settings, ok!


The NDK Builder is configured so that it will be compiled automatically when you save the clean project or modify the file.

Clean will see eclipse start to automatically compile, compile and run to the Android device, you will see HELLOJNI, so that the environment is built successfully.



The environment is very easy to build because of the use of the set ADT version of Eclipse. If you are using a different version, you will need to install the ANDROIDSDK and ADT, CDT plugins yourself. Be sure to note that the ADT version corresponds to the version of ANDROIDSDK! The CDT version corresponds to the version of Eclipse!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.