当前位置:网站首页>mk file introduction
mk file introduction
2022-08-11 06:35:00 【The rest of my life love static】
Introduction to Android.mk:
The Android.mk file is used to tell the NDK Build system about the Source.Android.mk will be part of the GNU Makefile and will be parsed by the Build System one or more times.
So, try to declare as few variables in Android.mk as possible, and don't assume anything won't be defined during parsing.
Android.mk file syntax allows us to package Source into a "modules", modules can be:
- Static library (.a file)
- Dynamic library (.so file)
Only dynamic libraries can be installed/copied into application packages (APK), static libraries can be linked into dynamic libraries.
You can define one or more modules in an Android.mk. You can also add the same source to multiple modules.
Build System handles a lot of details for us and doesn't need us to care anymore.For example: you don't need to list header files and external dependencies in Android.mk.
NDK Build System provides this information for us automatically.This also means that when users upgrade the NDK, you can benefit from the new toolchain/platform without having to modify Android.mk.
Android.mk syntax
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := VideoJniLOCAL_CFLAGS := -DWEBRTC_POSIX -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_HLOCAL_CPPFLAGS :=-std=c++11LOCAL_LDLIBS :=-llog -lcLOCAL_C_INCLUDES := \$(LOCAL_PATH)/webrtc \$(LOCAL_PATH)/speex/includeLOCAL_SRC_FILES := \com_example_videoclient_VideoJni.cpp \$(AUDIO_SRC_PATH)/Host.cpp \speex/libspeex/bits.c \include $(BUILD_SHARED_LIBRARY)1, LOCAL_PATH
LOCAL_PATH := $(call my-dir)Each Android.mk file must start with the definition LOCAL_PATHwhich is used to find source files in the development tree; macros my-dirstrong> is provided by Build System and returns the directory path containing Android.mk.
2, CLEAR_VARS
include $(CLEAR_VARS)The CLEAR_VARS variable is provided by the Build System and points to a specific GNU Makefile, which is responsible for cleaning up many LOCAL_xxx.For example: LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, etc.But if LOCAL_PATH is not cleaned up, this cleaning action is necessary, because all compilation control files are parsed and executed by the same GNU Make, and their variables are global, so they can avoid mutual influence after cleaning.
3, LOCAL_MODULE
LOCAL_MODULE := VideoJniThe LOCAL_MODULE module must be defined to represent every module in Android.mk.First names must be unique and contain no spaces.
The Build System will automatically add the appropriate prefix and suffix.For example, VideoJni, to generate a dynamic library, generate libVideoJni.so.But please note: If the module name is set as: libxxx, libxxx.so will be generated without prefix.
4, LOCAL_CFLAGS
LOCAL_CFLAGS := -DWEBRTC_POSIX -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_HAdditional compilation parameters provided to the C/C++ compiler, such as specifying all warnings as error, specifying optimization levels, such as: LOCAL_CFLAGS := -Werror
5, LOCAL_CPPFLAGS
LOCAL_CPPFLAGS :=-std=c++11Define extra flags for C++ files
6, LOCAL_LDLIBS
LOCAL_LDLIBS :=-llog -lcSpecify the link library that the program depends on, -llog links the Android NDK log library -lc links the C language library
7. LOCAL_C_INCLUDES
LOCAL_C_INCLUDES := \$(LOCAL_PATH)/webrtc \$(LOCAL_PATH)/speex/include8, LOCAL_SRC_FILES
Header file path required for C/C++
LOCAL_SRC_FILES := \com_example_videoclient_VideoJni.cpp \$(AUDIO_SRC_PATH)/Host.cpp \speex/libspeex/bits.c \All source files
contained in the current module9, BUILD_SHARED_LIBRARY
include $(BUILD_SHARED_LIBRARY)BUILD_SHARED_LIBRARY is a Build System-provided variable that points to a GNU Makefile Script.It is responsible for collecting all LOCAL_XXX information since the last call to include $(CLEAR_VARS) and deciding what to compile.
- BUILD_STATIC_LIBRARY: Compile as a static library
- BUILD_SHARED_LIBRARY: Compile as dynamic library
- BUILD_EXECUTABLE: Compile to Native C executable program
边栏推荐
- openlayer中实现截图框截图的功能
- Event Preview | On April 23, a number of wonderful sharing sessions of OpenMLDB will come, which will live up to the good time of the weekend
- JS案例练习(pink老师经典案例)
- The whole process of Tinker access --- Compilation
- OpenMLDB官网升级,神秘贡献者地图带你快速进阶
- Compilation exception resolution
- vim 编辑解决中文乱码问题
- C语言实现简易扫雷(附带源码)
- 活动预告 | 4月23日,多场OpenMLDB精彩分享来袭,不负周末好时光
- Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched
猜你喜欢
随机推荐
编译异常解决
实时特征计算平台架构方法论和基于 OpenMLDB 的实践
Intelligent risk control China design and fall to the ground
scanf函数在混合接受数据(%d和%c相连接)时候的方式
USB URB
Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain
ARM assembly instruction ADR and LDR
Promise.race学习(判断多个promise对象执行最快的一个)
stack stack
IIC 和 SPI
谨此留个纪念
Tinker的自我介绍
Interpretation of the paper: Cross-Modality Fusion Transformer for Multispectral Object Detection
Day 85
helm安装
STM32学习笔记(白话文理解版)—外部IO中断实验
127.0.0.1 已拒绝连接
哥德巴赫猜想与整数环
Day 67
[Meetup] OpenMLDBxDolphinScheduler engineering and scheduling link link characteristics, building the end-to-end MLOps workflow









