上一篇说的实际是调用自己生成的库
1、现在开始f fmpeg的--
库移到 /armeabi-v7a 后报这个错
2 files found with path 'lib/armeabi-v7a/libavcodec.so' from inputs:
cmakefile.txt里用这两行替代
set(FF ${CMAKE_SOURCE_DIR}/../../../libs/armeabi-v7a/)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${FF}")
这样可以编出 apk了,但是运行还出错,报这个
java.lang.UnsatisfiedLinkError: dlopen failed: library "libnativeffmpeg.so" not found,工程库找不到,奇怪。
2 现在用
arm64-v8a的,因为怀疑是虚拟机是arm64-v8a的,所以自动找arm64-v8a的库,没有就报错
但是现在链接有问提
Build command failed. Error while executing process /Users/wangt/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/.cxx/Debug/6m17615i/arm64-v8a nativeffmpeg} ninja: Entering directory `/Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/.cxx/Debug/6m17615i/arm64-v8a' [1/1] Linking CXX shared library /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/build/intermediates/cxx/Debug/6m17615i/obj/arm64-v8a/libnativeffmpeg.so FAILED: /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/build/intermediates/cxx/Debug/6m17615i/obj/arm64-v8a/libnativeffmpeg.so : && /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/wangt/Library/Android/sdk/ndk/21.4.7075529/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 -Wformat -Werror=format-security -L/Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a/ -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libnativeffmpeg.so -o /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/build/intermediates/cxx/Debug/6m17615i/obj/arm64-v8a/libnativeffmpeg.so CMakeFiles/nativeffmpeg.dir/native-lib.cpp.o -lavfilter -lavcodec -lavformat -lavutil -lpostproc -lswresample -lswscale -llog -latomic -lm && : /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libavfilter.so when searching for -lavfilter /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lavfilter /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libavcodec.so when searching for -lavcodec /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lavcodec /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libavformat.so when searching for -lavformat /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lavformat /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libavutil.so when searching for -lavutil /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lavutil /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libpostproc.so when searching for -lpostproc /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lpostproc /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libswresample.so when searching for -lswresample /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lswresample /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/wangt/AndroidStudioProjects/NativeFfmpeg/app/src/main/cpp/../../../libs/arm64-v8a//libswscale.so when searching for -lswscale /Users/wangt/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lswscale clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
3看来还是和库编译有关
is unable to create an executable file. C compiler test failed.
经常出现这个,观察了下 ,这个改成带版本的,因为 有aarch64-linux-android21-clang程序
--cross-prefix=$TOOLCHAIN/bin/aarch64-linux-android21- \
但是 又报nm的,于是
--nm=$TOOLCHAIN/bin/aarch64-linux-android-nm \
拷贝过去OK了,最终版
!/bin/bash make clean # NDK的路径,根据自己的安装位置进行设置 export NDK=/Users/wangt/Library/Android/sdk/ndk/21.4.7075529 export SYSROOT=$NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/ export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64/ export CPU=arm export ADDI_CFLAGS="-marm" export PREFIX=$(pwd)/android/ COMMON_OPTIONS="\ --prefix=android/ \ --target-os=android \ --enable-shared \ --enable-runtime-cpudetect \ --enable-small \ --disable-static \ --disable-debug \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-doc \ --disable-symver \ --disable-asm \ --disable-stripping \ --disable-armv5te \ " function build_android { echo "开始编译FFmpeg..." # arm64-v8a echo "开始编译FFmpeg(arm64-v8a)" ./configure \ --libdir=${PREFIX}/libs/arm64-v8a \ --incdir=${PREFIX}/include/arm64-v8a \ --pkgconfigdir=${PREFIX}/pkgconfig/arm64-v8a \ --arch=aarch64 \ --cpu=armv8-a \ --cross-prefix=$TOOLCHAIN/bin/aarch64-linux-android21- \ --nm=$TOOLCHAIN/bin/aarch64-linux-android-nm \ --sysroot=$SYSROOT \ --extra-ldexeflags=-pie \ ${COMMON_OPTIONS} make clean make -j8 && make install echo "结束编译FFmpeg(arm64-v8a)" echo "编译结束" }; build_android