Android.mk、 Application.mk 、CMakeLists.txt

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_ARM_MODE  := arm
LOCAL_MODULE    := vc
LOCAL_SRC_FILES := VideoChat.cpp \
                   VideoChat_jni.cpp \
                   json.c      

LOCAL_CPPFLAGS   += -funwind-tables -Wl,--no-merge-exidx-entries
LOCAL_CPPFLAGS   += -fexceptions -lstdc++
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/include
LOCAL_CFLAGS     += -g -DUSEFFMPEG 
LOCAL_LDFLAGS    += $(LOCAL_LDFLAGS) -L$(LOCAL_PATH)/$(TARGET_ARCH_ABI)/lib  -landroid -llog -lOpenSLES -lGLESv2 \
			       -Wl,--start-group \
                   -lrtmp \
                   -lavcodec \
                   -lavutil \
                   -lpostproc \
                   -lspeex \
                   -lspeexdsp \
                   -lWrap -Wl,--end-group

#LOCAL_LDLIBS := 
include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_ABI :=  armeabi
APP_PLATFORM := android-9
NDK_TOOLCHAIN_VERSION := 4.6

CMakeLists.txt

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.
# 设置构建本机库所需的CMake的最小版本。
cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

# 创建并命名库,将其设置为静态或共享,并提供到其源代码的相对路径。
#您可以定义多个库,CMake为您构建它们。
# Gradle自动将共享库打包到APK中。
add_library( # Sets the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             native-lib.cpp )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

# 搜索指定的预构建库并将路径存储为变量。
# 因为CMake在搜索路径by中包含了系统库默认情况下,
# 您只需要指定公共NDK库的名称 CMake验证库之前是否存在完成构建。
find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

#指定库CMake应该链接到目标库。你可以链接多个库,比如您在本文中定义的库构建脚本、预构建的第三方库或系统库
target_link_libraries( # Specifies the target library.
                       native-lib

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )
发布了134 篇原创文章 · 获赞 197 · 访问量 41万+

猜你喜欢

转载自blog.csdn.net/u011733020/article/details/101290058