NDK开发趟坑之旅
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再改回去,再次编译安装,就没有问题了~,但是再次打包的时候会接着报错,所以我只要放终极大招了,两种so我都放进去然后再打包,就是下面这个样子~
其实虽然是两份,但是它们是依赖关系,而且大小并没有增加一倍,在编译ffmpeg库文件的时候,lib库里面就是这些内容,库并没有生成两份,你会发现大小不一样,在mac上体现的比较好,大小和关系都有
再看下ffmpeg编译之后lib里面的关联
是不是明白了,后缀不带数字的会指向带有数字的so文件,这个后缀其实就是库的版本,因为ffmpeg在不断迭代,所以库的版本也在不断更新,好了,到此我们的库就告一段落了~
本文地址:https://blog.csdn.net/lancelots/article/details/108875118