# Sets the minimum version of CMake required to build the native library.
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.
//? ?第一步就是加入直接的編寫的c++文件。篮迎。男图。
add_library(# Sets the name of the library.
? ? ? ? ? ? mp3-lite
? ? ? ? ? ? # Sets the library as a shared library.
? ? ? ? ? ? SHARED
? ? ? ? ? ? # Provides a relative path to your source file(s).
? ? ? ? ? ? src/main/cpp/audio_lame.c
? ? ? ? )
//加入要引用的c++庫(kù)。甜橱。逊笆。
add_library(mp3lame
SHARED
? ? ? ? ? ? IMPORTED )
//設(shè)置要加入的動(dòng)態(tài)鏈接庫(kù)的地址。岂傲。难裆。。
set_target_properties(mp3lame
PROPERTIES IMPORTED_LOCATION
? ? ? ? ? ? ../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libmp3lame.so )
//設(shè)置CMAKE_CXX_FLAGS?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
//這是在引入頭文件。乃戈。
include_directories(src/main/cpp)
//找到ndk自帶的動(dòng)態(tài)鏈接庫(kù)褂痰。。
find_library(# Sets the name of the path variable.
? ? ? ? ? ? ? log-lib
? ? ? ? ? ? ? log )
//把所有的庫(kù)鏈接到我們寫的第一個(gè)庫(kù)上症虑。缩歪。。谍憔。完成匪蝙。。习贫。逛球。
target_link_libraries(# Specifies the target library.
? ? ? ? ? ? ? ? ? ? ? mp3-lite
? ? ? ? ? ? ? ? ? ? mp3lame
? ? ? ? ? ? ? ? ? ? ? # Links the target library to the log library
? ? ? ? ? ? ? ? ? ? ?# included in the NDK.
? ? ? ? ? ? ? ? ? ? ? ${log-lib} )