当前位置:网站首页>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 := VideoJni
The 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_H
Additional 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++11
Define extra flags for C++ files
6, LOCAL_LDLIBS
LOCAL_LDLIBS :=-llog -lc
Specify 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/include
8, 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
边栏推荐
- Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched
- The whole process of Tinker access --- Compilation
- 何凯明新作ViTDET:目标检测领域,颠覆分层backbone理念
- 深度学习Matlab工具箱代码注释
- STM32F4-正点原子探索者-SYSTEM文件夹下的delay.c文件内延时函数详解
- STM32-库函数-SetSysClock(void)函数解析-正点原子探索者
- SearchGuard configuration
- SearchGuard证书配置
- 红外线一认识
- Manufacturer Push Platform-Huawei Access
猜你喜欢
STM32学习笔记(白话文理解版)—外部IO中断实验
STM32学习笔记(白话文理解版)—小灯的点亮、闪烁、呼吸
OpenMLDB:线上线下一致的生产级特征计算平台
STM32学习总结(二)——GPIO
栈stack
vscode插件开发——代码提示、代码补全、代码分析
[Meetup]OpenMLDBxDolphinScheduler 链接特征工程与调度环节,打造端到端MLOps工作流
mk文件介绍
127.0.0.1 connection refused
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
随机推荐
论文解读TransFG: A Transformer Architecture for Fine-grained Recognition
经纬度求距离
js常用方法对象及属性
js 学习进阶(Dom部分 pink老师教学笔记)
Manufacturer Push Platform-Huawei Access
Minutes of OpenMLDB Meetup No.2
Typescript学习日记,typescript从基础到进阶(第一章)
jdbc接口文档参考,jdbc接口方法逻辑探究
关于openlayer中swipe位置偏移的问题
蓝牙技术-简介
OpenMLDB + Jupyter Notebook:快速搭建机器学习应用
STM32 基于固件库的工程模板的建立
OpenMLDB: Consistent production-level feature computing platform online and offline
编译异常解决
C语言实现简易扫雷(附带源码)
精彩联动 | OpenMLDB Pulsar Connector原理和实操
Simple mine sweeping in C language (with source code)
mysql basic summary
Error: Flash Download failed - “Cortex-M4“-STM32F4
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