Cocos2d-x 2.2.3 Use NDK to configure the compilation environment

https://blog.csdn.net/wwj_748/article/details/30072379

June 11, 2014 

The configuration of the development environment below Cocos2d-x 3.0 is probably tormenting many people. Using cygwin to configure the compilation environment is enough to make beginners feel pained for a while. This blog is to solve this problem, but the NDK version needs to be above ndk8, otherwise cygwin must be used.

The construction of the previous Android development environment is the premise. This blog will mainly focus on how to configure the NDK compilation environment in Eclipse. There is not much content.

1. Import the Android project in the created Cococs2dx project. Here is an example of TestApp:
Project reference path: D:\software\cocos2d-x-2.2.3\projects\TestApp
The approximate path of the project import library: D:\software\cocos2d-x-2.2.3\cocos2dx\platform\android\java
Here the author directly copied the src package introduced into the library project, such as org.cocos2dx.lib as shown in the figure, and also copied the related resources into the project. The approximate path is: D:\software\cocos2d- x-2.2.3\projects\TestApp\Resources, copy the resources to the assets directory in the target project



Second, the configuration environment
Configure NDK path:
The reference path is: D:\software\android-ndk-r9d

Configure NDK commands:
Reference command: D:\software\android-ndk-r9d\ndk-build.cmd 



Add NDK module path (reference, as appropriate):
Operation steps: Eclipse->Windows->Preferences->C/C++->Build->Environment->ADD
NDK_MODULE_PATH
D:/software/cocos2d-x-2.2.3;D:/software/cocos2d-x-2.2.3/cocos2dx/platform/third_party/android\prebuilt
As shown below:


As long as it is configured here once, there is no need to configure the C/C++ environment in a specific project in the future.
注:D:/cocos2d-x-2.2.3;D:/cocos2d-x-2.2.3/cocos2dx/platform/third_party/android/prebuilt
The path should use "/", not "\" , otherwise the following error will occur: (2014-6-15 correction)


**** Build of configuration Default for project Test3 ****


D:\android-ndk-r9d\ndk-build.cmd 
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml    
Android NDK: WARNING: Ignoring unknown import directory: D:\cocos2d-x-2.2.3    
Android NDK: jni/Android.mk: Cannot find module with tag 'cocos2dx' in import path    
jni/Android.mk:23: *** Android NDK: Aborting.    .  Stop.
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?    
Android NDK: The following directories were searched:    
Android NDK:         


**** Build Finished ****


到这里关于编译的环境的配置基本上已经完了。


直接run我们的项目,如果编译成功的话,会生成对应的libs目录和obj目录:


不知道笔者把配置过程说清楚了没有,如有疑问,可以留言交流。
本人技术群:299402133,移动开发狂热者,等你的光临。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324668529&siteId=291194637