1. 使用cmake编译LAME
首先先把libmp3lame中的.c和.h文件(里面文件夹不用管)以及include中的lame.h复制到cpp中,也可以创建文件夹方便管理。
修改CMakeList.txt文件,设置动态库的地址我一直出问题,明明可以指向外面的libs,但是它不能在外面的libs创建,只会在cpp里再创建libs。不知道为啥。
CMakeList.txt文件内容:
cmake_minimum_required(VERSION 3.18.1)
project("testlame")
// 设置动态库的存放地址
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${
PROJECT_SOURCE_DIR}/libs/${
ANDROID_ABI})
#add_executable(demo demo.cpp) # 生成可执行文件
add_library( # Sets the name of the library.
lame-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp
lame/bitstream.c
lame/encoder.c
lame/fft.c
lame/gain_analysis.c
lame/id3tag.c
lame/lame.c
lame/mpglib_interface.c
lame/newmdct.c
lame/presets.c
lame/psymodel.c
lame/quantize.c
lame/quantize_pvt.c
lame/reservoir.c
lame/set_get.c
lame/tables.c
lame/takehiro.c
lame/util.c
lame/vbrquantize.c
lame/VbrTag.c
lame/version.c )
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)
target_link_libraries( # Specifies the target library.
lame-lib
# Links the target library to the log library
# included in the NDK.
${
log-lib})
修改build-gradle文件
android{
externalNativeBuild {
cmake {
cppFlags '-frtti -fexceptions'
cFlags '-DSTDC_HEADERS'
}
}
ndk {
abiFilters 'armeabi-v7a','arm64-v8a'
}
}
然后就可以去试试看看能不能引用了
FDK_AAC编译
https://blog.csdn.net/KayChanGEEK/article/details/103216139
然后open object 进入vs里面进行编译,然后他会在build文件夹里生成DEBUG,里面就是编译后的成品。
X264编译
https://blog.csdn.net/mytzs123/article/details/123284565
最后需要make的时候可能会提示:没有make这个命令,只需要下载https://www.benequidem.eu/index.php/download/make/
这个然后解压和msys2放在一个文件夹里就行。