Cocos porting to android-android.mk compiled file

Source: Internet
Author: User

We used the Cocos tool to compile C and C + + source code in our previous blog. In fact Cocos Tools read < Game Engineering Catalog >\proj.android\jni\ directory android.mk files, for cross-compiling and packaging.
ANDROID.MK is a compiled file, which is a small part of the GNU makefile and is used to describe C and C + + source code files to the Android NDK, how to compile, and to package operations. The default Android.mk file contents are as follows:
Local_path: = $ (call My-dir) ①include $ (clear_vars) ②local_module: = Cocos2dcpp_shared③local_module_filename: = Libcocos2dcpp④local_src_files: = Hellocpp/main.cpp                    . /.. /classes/appdelegate.cpp.                    /.. /classes/helloworldscene.cpp⑤local_c_includes: = $ (Local_path)/. /.. /classes⑥local_whole_static_libraries: = cocos2dx_static⑦local_whole_static_libraries + = Cocosdenshion_staticLOCAL _whole_static_libraries + = Box2d_staticinclude $ (build_shared_library) ⑧$ (call import-module,2d) ⑨$ (call Import-module,audio/android) $ (call import-module,box2d)


Here we explain the meaning of these items, ① line Local_path is the definition of the current directory variable, the variable must be defined, where MY-DIR macro, call My-dir is to return the current directory. The ② line code include $ (clear_vars) clears the local open variable, but does not include Local_path, because all variables are global.
The ③ Line code defines the Local_module variable, which must be defined to identify each module described in the Android.mk file. The name must be unique and does not contain any spaces. The ④ Line code defines the Local_module_filename variable, which is optional and allows you to redefine the name of the generated file. The filename generated in this example is libcocos2dcpp.so file.
The ⑤ Line code defines the Local_src_files variable, which describes the list of source files that will be compiled in the module. The ⑥ Line code defines the Local_c_includes variable, specifying the header file search path logical list. The ⑦ Line code defines the local_whole_static_libraries variable, which is used to specify the library module to connect to.
The ⑧ line code is include $ (build_shared_library) to generate a dynamic-link library (or shared library) that is compiled, and the file is named lib< Library module name >.so. In addition, we can use Build_static_library to tell the compilation system to generate a static link library, the file command for the lib< Library module name &GT;.A.
The ⑨ line code $ (call import-module,2d) is a android.mk that contains another module through the directory name, where 2d is the module directory name.

The hint Library is a collection of program code that does not have a main function. Libraries are divided into: Static link libraries and dynamic link libraries, the difference is that the static link library can be compiled into your execution code, the application can run in an environment without a static link library, the dynamic link library can not be compiled into your execution code, the application must be in the context of a linked library file run. In Microsoft Windows and Windows Phone Platform dynamic link library files are. dll files, static link libraries are. lib files, and the dynamic link library files on Linux and Android platforms are. So files, static link libraries are. a files; Mac OS Platform dynamic link library files such as x and iOS are. dylib files, and static link libraries are. a files.


For more information, please pay attention to the first Cocos2d-x 3.2 Edition book "Cocos2d-x: C + + volume" book Exchange discussionwebsite: http://www.c ocoagame.net
For more exciting video courses, please follow Cocos class: http://v.51work6.com
Welcome to join Cocos2d-x Technical Discussion group: 257760386 Welcome to Luxgen iOS Classroom public platform

Cocos porting to android-android.mk compiled file

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.