Android Studio uses cmake to compile LAME, FDK_AAC, X264

1. Use cmake to compile LAME

First, copy the .c and .h files in libmp3lame (don’t worry about the folder inside) and the lame.h in include to cpp, and you can also create a folder for easy management.
insert image description here
I have been having problems modifying the CMakeList.txt file and setting the address of the dynamic library. Obviously, it can point to external libs, but it cannot be created in external libs, and will only create libs in cpp. I don't know why.
CMakeList.txt file content:

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})

Modify build-gradle file

android{
    
    
		externalNativeBuild {
    
    
        	cmake {
    
    
                cppFlags '-frtti -fexceptions'
                cFlags '-DSTDC_HEADERS'
            }
        }
        ndk {
    
    
            abiFilters 'armeabi-v7a','arm64-v8a'
        }
}

insert image description here
Then you can try to see if you can quote it.
insert image description here

FDK_AAC compilation

https://blog.csdn.net/KayChanGEEK/article/details/103216139

Then the open object enters the vs to compile, and then he will generate DEBUG in the build folder, which is the finished product after compilation.

insert image description here

X264 compilation

https://blog.csdn.net/mytzs123/article/details/123284565

Finally, when you need make, you may be prompted: there is no make command, just download https://www.benequidem.eu/index.php/download/make/
and then unzip it and put it in a folder with msys2.

Guess you like

Origin blog.csdn.net/A_easy_learner/article/details/123310893