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} )
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章