android如何编译lame,Android 编译 Lame 库心路历程
編譯腳本
lame 版本
下載完成后 編譯 生成
include
lib
兩個(gè)文件夾
直接拷貝到 lib 目錄下
集成
然后
CMakeList 里面添加頭文件路徑 不做這一步 后面無(wú)法在 C++文件里面include
include(libs/include/lame/lame.h)
更簡(jiǎn)單的 可以直接添加目錄
include_directories(libs/include)
添加靜態(tài)庫(kù)鏈接 這一步忘記了會(huì)導(dǎo)致編譯報(bào)錯(cuò)
add_library(mp3lame STATIC IMPORTED)
set_target_properties(mp3lame
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/armeabi-v7a/libmp3lame.a)
target_link_libraries( # Specifies the target library.
native-lib
mp3lame
# Links the target library to the log library
# included in the NDK.
${log-lib})
完整的 CMake
# 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_minimum_required(VERSION 3.4.1)
set(distribution_DIR ../../../../libs)
include_directories(libs/include)
# 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.
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).
src/main/cpp/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.
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.
target_link_libraries( # Specifies the target library.
native-lib
mp3lame
# Links the target library to the log library
# included in the NDK.
${log-lib})
add_library(mp3lame STATIC IMPORTED)
set_target_properties(mp3lame
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/armeabi-v7a/libmp3lame.a)
CMake編譯
needed by錯(cuò)誤
一定是路徑設(shè)置不對(duì)
.a文件呢或者.so文件設(shè)置不對(duì)
總結(jié)出,NDK 中引入別的庫(kù)
下載庫(kù) 交叉編譯庫(kù) .a .so 不一定要編譯,也可以源碼代入
導(dǎo)入 AndroidStudio,編寫(xiě) CMake,導(dǎo)入頭文件
編譯相關(guān)源代碼
build 出相應(yīng)的 so
參考
總結(jié)
以上是生活随笔為你收集整理的android如何编译lame,Android 编译 Lame 库心路历程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 陶瓷锅第一次用需要怎么处理锅(陶瓷锅)
- 下一篇: 零购商城官网(零购官网商家入驻)