错误信息:
Build command failed.
Error while executing process D:\Android\SDK\android-sdk-windows\cmake\3.6.4111459\bin\cmake.exe with arguments {--build E:\demo\20200427\2\GB28181Android-master\gb28181library\.externalNativeBuild\cmake\debug\arm64-v8a --target gb_native}
[1/4] Building CXX object CMakeFiles/gb_native.dir/src/main/cpp/gb28181_muxer.cpp.o
[2/4] Building CXX object CMakeFiles/gb_native.dir/src/main/cpp/gb_native.cpp.o
[3/4] Building CXX object CMakeFiles/gb_native.dir/src/main/cpp/GB28181_sender.cpp.o
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb_native.cpp:5:
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/gb28181_muxer.h:10:
错误1:
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/user_arguments.h:8:1: warning: typedef requires a name [-Wmissing-declarations]
typedef struct UserArguments {
^~~~~~~
1 warning generated.
FAILED: D:\Android\SDK\android-sdk-windows\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=D:/Android/SDK/android-sdk-windows/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=D:/Android/SDK/android-sdk-windows/ndk-bundle/sysroot -Dgb_native_EXPORTS -isystem D:/Android/SDK/android-sdk-windows/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem D:/Android/SDK/android-sdk-windows/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -isystem D:/Android/SDK/android-sdk-windows/ndk-bundle/sysroot/usr/include/aarch64-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++14 -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/gb_native.dir/src/main/cpp/GB28181_sender.cpp.o -MF CMakeFiles\gb_native.dir\src\main\cpp\GB28181_sender.cpp.o.d -o CMakeFiles/gb_native.dir/src/main/cpp/GB28181_sender.cpp.o -c E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\GB28181_sender.cpp
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\GB28181_sender.cpp:6:
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/GB28181_sender.h:20:
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/user_arguments.h:8:1: warning: typedef requires a name [-Wmissing-declarations]
typedef struct UserArguments {
^~~~~~~
问题2
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\GB28181_sender.cpp:70:66: warning: format specifies type 'long long' but the argument has type 'unsigned long' [-Wformat]
LOGI("[sender]read from queue%lld\t I/O time%lld", t1 - start_t, t2 - t1);
~~~~ ^~~~~~~~~~~~
%lu
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\GB28181_sender.cpp:70:80: warning: format specifies type 'long long' but the argument has type 'unsigned long' [-Wformat]
LOGI("[sender]read from queue%lld\t I/O time%lld", t1 - start_t, t2 - t1);
~~~~ ^~~~~~~
%lu
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
问题3
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\GB28181_sender.cpp:152:17: error: no viable conversion from '__bind
int ret = bind(sockfd, (struct sockaddr *) &client_addr, sizeof(client_addr));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 1 error generated.
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:2:
In file included from E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/gb28181_muxer.h:10:
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/user_arguments.h:8:1: warning: typedef requires a name [-Wmissing-declarations]
typedef struct UserArguments {
^~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:33:27: warning: 'codec' is deprecated [-Wdeprecated-declarations]
pCodecCtx = video_st->codec;
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavformat/avformat.h:892:5: note: 'codec' has been explicitly marked deprecated here
attribute_deprecated
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavcodec/../libavutil/attributes.h:94:49: note: expanded from macro 'attribute_deprecated'
# define attribute_deprecated __attribute__((deprecated))
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:54:10: warning: format specifies type 'long long' but the argument has type 'int64_t' (aka 'long') [-Wformat]
arguments->video_bit_rate,
^~~~~~~~~~~~~~~~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:102:20: warning: 'avpicture_get_size' is deprecated [-Wdeprecated-declarations]
picture_size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavformat/../libavcodec/avcodec.h:5536:1: note: 'avpicture_get_size' has been explicitly marked deprecated here
attribute_deprecated
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavcodec/../libavutil/attributes.h:94:49: note: expanded from macro 'attribute_deprecated'
# define attribute_deprecated __attribute__((deprecated))
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:133:65: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
LOGI("[muxer][send in]send raw Frame to queue time%lld", et - st);
~~~~ ^~~~~~~
%ld
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:171:5: warning: 'avpicture_fill' is deprecated [-Wdeprecated-declarations]
avpicture_fill((AVPicture *) pNewFrame, buf, gb28181Muxer->pCodecCtx->pix_fmt, gb28181Muxer->pCodecCtx->width,
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavformat/../libavcodec/avcodec.h:5521:1: note: 'avpicture_fill' has been explicitly marked deprecated here
attribute_deprecated
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavcodec/../libavutil/attributes.h:94:49: note: expanded from macro 'attribute_deprecated'
# define attribute_deprecated __attribute__((deprecated))
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:205:126: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
LOGI("[muxer][encode]fetch raw frame from queue time%lld (video frame queue left%d)in FFmpeg time%lld.", et1 - st, gb28181Muxer->video_queue.size(), et2 - et1);
~~~~ ^~~~~~~~
%ld
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:205:170: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
LOGI("[muxer][encode]fetch raw frame from queue time%lld (video frame queue left%d)in FFmpeg time%lld.", et1 - st, gb28181Muxer->video_queue.size(), et2 - et1);
~~~~ ^~~~~~~~~
%ld
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:234:22: warning: format specifies type 'long long' but the argument has type 'int64_t' (aka 'long') [-Wformat]
gb28181Muxer->nowPkt->pts, gb28181Muxer->video_queue.size());
^~~~~~~~~~~~~~~~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:252:86: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
gb28181Muxer->video_queue.size(), gb28181Muxer->audio_queue.size(), et - st);
^~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:389:33: warning: 'codec' is deprecated [-Wdeprecated-declarations]
avcodec_close(video_st->codec);
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavformat/avformat.h:892:5: note: 'codec' has been explicitly marked deprecated here
attribute_deprecated
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavcodec/../libavutil/attributes.h:94:49: note: expanded from macro 'attribute_deprecated'
# define attribute_deprecated __attribute__((deprecated))
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:428:10: warning: format specifies type 'long long' but the argument has type 'int64_t' (aka 'long') [-Wformat]
gb28181Muxer->nowPkt->pts,
^~~~~~~~~~~~~~~~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:429:10: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
gb28181Muxer->nextPkt->pts - gb28181Muxer->nowPkt->pts,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:430:10: warning: format specifies type 'long long' but the argument has type 'int64_t' (aka 'long') [-Wformat]
gb28181Muxer->nextPkt->pts, audioCnt);
^~~~~~~~~~~~~~~~~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/log.h:12:71: note: expanded from macro 'LOGI'
#define LOGI(...) if(DEBUG){__android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__);} // LOGI
^~~~~~~~~~~
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp\gb28181_muxer.cpp:468:5: warning: 'av_free_packet' is deprecated [-Wdeprecated-declarations]
av_free_packet(gb28181Muxer->nowPkt);
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavformat/../libavcodec/avcodec.h:4533:1: note: 'av_free_packet' has been explicitly marked deprecated here
attribute_deprecated
^
E:\demo\20200427\2\GB28181Android-master\gb28181library\src\main\cpp/include/libavcodec/../libavutil/attributes.h:94:49: note: expanded from macro 'attribute_deprecated'
# define attribute_deprecated __attribute__((deprecated))
^
15 warnings generated.
ninja: build stopped: subcommand failed.
解决方案:
问题1:上图为解决方案: 类型后面添加 userArguments
问题2: LOGI("[sender]read from queue:%lld\t I/O time:%lld", t1 - start_t, t2 - t1);中打印类型出错,
将 %lld 改成 %lu, lu表示无类型参数
问题3:int ret = bind(sockfd, (struct sockaddr *) &client_addr, sizeof(client_addr));
改为 int ret = ::bind(sockfd, (struct sockaddr *) &client_addr, sizeof(client_addr));
::表示不调用标准库