How to compile and compile a self-created Cocos2dx project in Ubuntu

Source: Internet
Author: User

I found a lot of information on the Internet, the results are if the Ubuntu compilation of the Cocos2d-x comes with a few examples. I was not familiar with makefile at the beginning, and it took a long time to complete the result. Here I will record it and provide a reference for those who need it. Don't take too many detours.

First run the create-android-project.sh to create a new project, I prefer to put the project together, better management, So I move the new project to the Projects/Cocos2dx directory under the current user directory.

Go to the proj. Android/jni directory, open Android. mk, and modify it as follows:
Set:
COCOS2DX_ROOT = "$ DIR /../.."
Changed:
COCOS2DX_ROOT = "$ DIR/../cocos2d-x-2.1.5/" # relative to the cocos2d-x directory of the current directory, This Is My directory
After saving the changes, you can run build_native.sh to compile the project in Android. If the error message "NDK_ROOT is not set, use export NDK_ROOT = (your NDK directory, is also relative to the current directory), for example, my is export NDK_ROOT = .. /.. /.. /.. /Android/ndk-r9

If you want to compile and run it in Ubuntu, follow these steps:

First create a new project to create a folder proj. linux, and then create a main. cpp file under proj. linux. The content is as follows:

<Stdlib. h> <stdio. h> <unistd. h> <> main (argc, *** elgView =-> setFrameSize (, CCApplication: sharedApplication ()->View Code

This code can also be copied directly in the example.
Create a new Makefile under proj. linux with the following content (you can also copy one from the example in the cocos2d-x and modify it according to your project ):

=-I .. -I .. /= main. /Classes/AppDelegate. /Classes/HelloWorldScene. = .. /.. /.. /.. /cocos2d-x -. # cocos2d-/cocos2dx/proj. linux/+ =-lcocos2d-= $ (LIB_DIR)/libcocos2d. so $ (LIB_DIR)/+ =-I $ (COCOS_ROOT)/CocosDenshion/--/%. o: %. -- c $ <-/%. o :.. /%. -- c $ <-o $ @View Code

Finally, run make DEBUG = 1 all in the proj. linux directory.
Of course, manual construction is too troublesome. You can also write a shell file for processing.

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.