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.