NDK開發趟坑之旅

lancelots發表於2020-09-29

Build command failed.
Error while executing process /Users/fenglei/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/fenglei/AndroidStudioProjects/FFmpegNdkDemo/app/.cxx/cmake/debug/armeabi-v7a native-lib}
ninja: Entering directory `/Users/fenglei/AndroidStudioProjects/FFmpegNdkDemo/app/.cxx/cmake/debug/armeabi-v7a'
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
clang++: warning: argument unused during compilation: '-L/Users/fenglei/AndroidStudioProjects/FFmpegNdkDemo/app/libs/armeabi-v7a' [-Wunused-command-line-argument]
[2/2] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so
FAILED: ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so 
: && /Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -std=c++11 -L/Users/fenglei/AndroidStudioProjects/FFmpegNdkDemo/app/libs/armeabi-v7a -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o  -lavcodec -lavfilter -lavformat -lavutil -lswresample -lswscale -llog -latomic -lm && :
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavcodec
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavfilter
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavformat
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lavutil
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lswresample
/Users/fenglei/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lswscale
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

這個報錯原因在於FFmpeg的so庫編譯後是帶有數字的,如下圖所示,

第一次編譯的時候把數字和-刪掉就沒有這個報錯了,然後你以為結束了,naive~,然後在安裝啟動的時候會接著報錯

是的,你沒有看錯,應用會接著找libavcodec-58.so,所以我們把剛剛改過名字的so再改回去,再次編譯安裝,就沒有問題了~

相關文章