Use eclipse CDT to develop cocos2dx for Android

Source: Internet
Author: User

I'm afraid I will forget it later.

Using CDT mainly involves code prompts, and eclipse is quite comfortable to use. Compilation is not configured, but cocos2dx gave a script: build_native.sh when generating the project. It is very convenient to call this script to execute the compilation. That is to say, you can write a script to complete compilation and deployment.

1. After a project is generated according to the document, use CDT to create a new project. Import the generated CPP (under the classes folder)

2. Right-click the project and choose Properties> C/C ++ build> setting to set cross g ++ compiler parameters. Mainly include. Because compilation is not involved, you do not need to set linker. Open the includes and add three include paths: $ cocos_root, $ cocos_root/platform, $ cocos_root/include, $ cocos_root/cocosdenshion. Note that $ cocos_root is the cocos2dx directory. The four paths refer to the build_native.sh script in the project we generated by cocos2dx. Carefully check the JNI/your_app/Android. mk of the generated project, which indicates the preceding include paths. Code prompts depend on them :)

3. Set the cross g ++ compiler parameter. Add defined symbols to the Preprocessor option. Because I am an android project, add an android program to enable Android-related macros.

After that, let's look at the files just imported. Is there less red lines? But there are many more. So proceed.

4. Take the longest time. To implement the code prompt function, eclipse CDT must first index the files used. However, if the project is very large, it will inevitably become very slow, so some restrictions are imposed, these restrictions are set in properties-> C/C ++ general-> indexer. The default skip address is too much. Open it all and change the Skip larger than from 8 m to 10 m. After OK, check whether all the import files are identified? Okay. Is there no red line?

5. Because we import the file, that is to say, the file we edited is copied to the eclipse workspace, and the modification will not affect the original code. For convenience, you can write a script:

# Dispatch. Sh

File_in_cdt =/usr/Kevin/worksapce/your_app

App_in_cocos2dx =/usr/Kevin/cocos2dx/your_app

File_in_cocos2dx = $ app_in_cocos2dx/classes

If [-d $ file_in_cocos2dx]; then

Rm-RF $ file_in_cocos2dx

Fi

Mkdir $ file_in_cocos2dx

CP-r $ file_in_cdt/* $ file_in_cocos2dx/

$ App_in_cocos2dx/build_native.sh

Related Article

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.