1、廢話linux
最近學習,第一步就是編譯.咱們須要編譯FFmpag,x264,fdk_aac,下面是x264,網上說的不少都是幾百年前的,我親測完美可用android
仍是那句話 我能力有限,可是我但願我寫的東西可以讓更多的人可以接受.我也是剛剛接觸.作一個記錄,也但願可以對其餘人有好處.
聯繫我能夠直接評論,也能夠加我QQ:2519687025git
2、乾貨
準備:1.fdk_aac的源碼 git clone https://android.googlesource.com/platform/external/aaceclipse
3.須要下載cmake 直接在cmd裏面就能夠了,以前的FFmpeg和x264都是cygwin裏面的.如今不用.須要設置cmake環境變量,加入到path裏面ide
4.編譯腳本.這個腳本本身去理解吧.我也是隻知其一;不知其二--腳本名稱:CMakeLists.txt學習
# source code: git clone https:
//
android.googlesource.com/platform/external/aac
cmake_minimum_required ( VERSION
2.8 )
if (CMAKE_SYSTEM_NAME STREQUAL Android )
if ( NOT CMAKE_SYSTEM_PROCESSOR )
set ( CMAKE_SYSTEM_PROCESSOR armeabi-v7a )
endif ()
if ( NOT CMAKE_SYSTEM_VERSION )
set ( CMAKE_SYSTEM_VERSION
8 )
endif ()
if ( NOT NDK_TOOLCHAIN_VERSION)
set ( NDK_TOOLCHAIN_VERSION
4.8 )
endif ()
set ( ANDROID_NDK_ROOT $ENV{ANDROID_NDK_ROOT} )
find_path ( TOOLCHAIN_ROOT bin PATHS ${ANDROID_NDK_ROOT}/toolchains/arm-linux-androideabi-${NDK_TOOLCHAIN_VERSION}/prebuilt
/*
)
include ( CMakeForceCompiler )
find_program ( CMAKE_C_COMPILER arm-linux-androideabi-gcc PATHS ${TOOLCHAIN_ROOT}/bin )
find_program ( CMAKE_CXX_COMPILER arm-linux-androideabi-g++ PATHS ${TOOLCHAIN_ROOT}/bin )
find_program ( CMAKE_AR arm-linux-androideabi-ar PATHS ${TOOLCHAIN_ROOT}/bin )
cmake_force_c_compiler ( ${CMAKE_C_COMPILER} GNU )
cmake_force_cxx_compiler ( ${CMAKE_CXX_COMPILER} GNU )
set ( CMAKE_SYSROOT ${ANDROID_NDK_ROOT}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-arm CACHE PATH "" )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endif ()
project ( fdk-aac )
if ( NOT INCLUDE_INSTALL_DIR )
set ( INCLUDE_INSTALL_DIR include )
endif ()
if ( NOT ARCHIVE_INSTALL_DIR )
set ( ARCHIVE_INSTALL_DIR lib/static )
endif ()
if ( NOT IS_DIRECTORY ${FDK_AAC_SOURCE_DIR} )
message ( FATAL_ERROR "FDK_AAC_SOURCE_DIR=${FDK_AAC_SOURCE_DIR} is not a dir" )
endif ()
if ( CMAKE_SYSTEM_NAME STREQUAL Android )
add_definitions (
--sysroot=${CMAKE_SYSROOT}
-fPIC
-march=armv7-a
-mfpu=vfpv3-d16
-DANDROID
-mhard-float
-D_NDK_MATH_NO_SOFTFP=1
-lm_hard )
endif ()
add_definitions (
-fno-rtti
-fno-exceptions )
set ( SOURCE_FILES )
foreach ( subdir
libAACdec libAACenc libFDK
libMpegTPDec libMpegTPEnc
libPCMutils
libSBRdec libSBRenc
libSYS )
set ( __inc_dir ${FDK_AAC_SOURCE_DIR}/${subdir}/include )
include_directories ( ${__inc_dir} )
install ( DIRECTORY ${__inc_dir}/ DESTINATION ${INCLUDE_INSTALL_DIR}/fdk-aac/ )
file ( GLOB __src_files
${FDK_AAC_SOURCE_DIR}/${subdir}/src/*.cpp
${FDK_AAC_SOURCE_DIR}/${subdir}/src/*.h )
list ( APPEND SOURCE_FILES ${__src_files} )
endforeach ()
add_library ( fdk-aac STATIC
${SOURCE_FILES} )
install ( TARGETS fdk-aac
ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR} )
3、編譯ui
這個的編譯相對簡單 ,只要下載cmake就能夠了.直接cmake就能夠了.google
1
.定位到編譯目錄
2.執行cmake 命令
cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Andr
oid -DFDK_AAC_SOURCE_DIR="E:/soft/source/fdk_aac/aac" E:\qupai_code_eclipse\code
\ThirdParty\Build\fdk-aac -DCMAKE_MAKE_PROGRAM=E:\android-ndk-r9c\prebuilt\windo
ws\bin\make.exeidea
3
.cmake --bulid . -- -j8
注意:DFDK_AAC_SOURCE_DIR="你的fdk_aac的源碼地址" spa
E:\qupai_code_eclipse\code\ThirdParty\Build\fdk-aac ----這裏是你的CMakeLists.txt地址
DCMAKE_MAKE_PROGRAM=NDK的make地址