【发布时间】:2017-09-16 07:40:11
【问题描述】:
我正在申请将手机视频播放到 youtube 频道。我找到了这个链接https://github.com/youtube/yt-watchme。
编译代码时出现错误
libavutil 未找到 在文件 avecode.h 中的代码 #include "libavutil/samplefmt.h
我也改成#include "../libavutil/samplefmt.h" 还是一样的错误。
也许建议任何好的 rtmp 库将手机视频广播到 youtube 频道。
错误:失败:构建失败并出现异常。 * 出了什么问题:
任务“:app:externalNativeBuildDebug”执行失败。
构建命令失败。
执行过程出错/Users/nomankhan/Library/Android/sdk/cmake/3.6.4111459/bin/cmake 带参数 {--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
失败:/Users/nomankhan/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=mips64el-none-linux-android --gcc-toolchain=/Users/ nomankhan/库/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 - I../../../../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)
【问题讨论】:
-
我相信您需要
include_directories(src/main/cpp)而不是最后三个语句。在 native-lib.cpp 你应该有#include "libavcodec/avcodec.h". -
@Noman 我也遇到了与您相同的错误。我正在构建简单的 cpp 文件,但我无法构建它。你可以看到我的代码stackoverflow.com/questions/51100111/…。
-
@AlexCohn 我还在我的 native-lib.cpp 文件中提到了标题,但仍然是我无法成功构建代码的原因。也可以看代码stackoverflow.com/questions/51100111/…
标签: android-studio compiler-errors java-native-interface