我正在申请向youtube频道播放手机视频。我找到了这个链接https://github.com/youtube/yt-watchme。
编译我的代码时出错
未找到libavutil 在文件avecode.h中的代码#include“libavutil / samplefmt.h
我也改为#include“../libavutil/samplefmt.h”仍然是同样的错误。
也许建议任何好的rtmp图书馆向youtube频道播放手机视频。
错误:FAILURE:构建因异常而失败。 *出了什么问题:
任务':app:externalNativeBuildDebug'执行失败 构建命令失败 执行进程时出错/Users/nomankhan/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Clients/Ankur/JniDemo/app/.externalNativeBuild/cmake/debug/mips64 --target native -lib}
[1/2]构建CXX对象CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o
FAILED:/ Users / nomankhan / Library / Android / sdk / ndk-bundle / toolchains / llvm / prebuilt / darwin-x86_64 / bin / clang ++ --target = mips64el-none-linux-android --gcc-toolchain = / Users / nomankhan / Library / Android / sdk / ndk-bundle / toolchains / mips64el-linux-android-4.9 / prebuilt / darwin-x86_64 --sysroot = / Users / nomankhan / Library / Android / sdk / ndk-bundle / sysroot -Dnative_lib_EXPORTS - 我../../../../ src / main / cpp / include / libavcodec -I ../../../../ src / main / cpp / include / libavformat -I ../ ../../../src/main/cpp/include/libavutil -isystem /Users/nomankhan/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /Users/nomankhan/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/include -isystem / Users / nomankhan / Library / Android / sdk / ndk-bundle / sources /cxx-stl/gnu-libstdc++/4.9/include/backward -isystem / Users / nomankhan / Library / Android / sdk / ndk-bundle / sysroot / usr / include / mips64el-linux-android -D__ANDROID_API __ = 21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protecto r-strong -no-canonical-prefixes -fintegrated-as -Wa, - noexecstack -Wformat -Werror = format-security -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles / native-lib.dir /src/main/cpp/native-lib.cpp.o -MF CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.od -o CMakeFiles / native-lib.dir / src / main /cpp/native-lib.cpp.o -c /Clients/Ankur/JniDemo/app/src/main/cpp/native-lib.cpp包含在/Clients/Ankur/JniDemo/app/src/main/cpp/native-lib.cpp:4中的文件:/Clients/Ankur/JniDemo/app/src/main/cpp/libavcodec/avcodec.h :31:10: 致命错误:找不到'libavutil / samplefmt.h'文件 #include“libavutil / samplefmt.h” ^ ~~~~~~~~~~~~~~~~~~~~~~
我的CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
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.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
include_directories(src/main/cpp/include/libavcodec)
include_directories(src/main/cpp/include/libavformat)
include_directories(src/main/cpp/include/libavutil)
答案 0 :(得分:2)
以下答案假设cpp
中的文件夹包含C ++代码/ src文件。如果没有,那么您可能会遇到代码和库结构问题。
只需调用include_directories
将而不是获取CMake
来编译它们,我相信它只会帮助IDE进行某些“语法突出显示”和编码相关的事情,但它很重要。
相反,您需要在add_library
调用中包含代码文件。由于很明显你有很多文件,因此遍历代码会有所帮助:
cmake_minimum_required(VERSION 3.4.1)
include_directories(src/main/cpp/include/libavcodec)
# Traverses through the directories recursively
# and append matching files to variable my_lib_SRC
file(GLOB_RECURSE my_lib_SRC
"src/main/cpp/*.h"
"src/main/cpp/*.cpp"
)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
${my_lib_SRC})
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
注意:每次添加新的源/代码文件时,都需要清理并再次构建项目,以便正确构建二进制文件。可以在此处找到进一步的解释:https://stackoverflow.com/a/17655165/2949966