请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

extr_video编译问题

老师,你好,编译出现了下面的错误,该如何解决呢?
我的系统是ubuntu 8

gcc -g -o extr_video extr_video.c `pkg-config --libs libavutil libavformat`

In file included from extr_video.c:4:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
/usr/bin/ld: /tmp/ccLEIP3g.o: undefined reference to symbol 'av_packet_free@@LIBAVCODEC_57'
//usr/lib/x86_64-linux-gnu/libavcodec.so.57: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

正在回答 回答被采纳积分+3

3回答

李超 2020-03-02 23:53:32

你加入到QQ群里提问吧,问答区看着不方便

0 回复 有任何疑惑可以回复我~
提问者 慕圣0365731 2020-03-02 23:51:47
下面两条命令都没有用:
root@ubuntu:~/coding-279# gcc -g -o extr_video extr_video.c `pkg-config --libs  --cflags  libavutil libavformat`
extr_video.c: In function ‘h264_mp4toannexb’:
extr_video.c:190:13: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
             h264_extradata_to_annexb( fmt_ctx->streams[in->stream_index]->codec->extradata,
             ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from extr_video.c:4:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
extr_video.c:191:39: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
                                       fmt_ctx->streams[in->stream_index]->codec->extradata_size,
                                       ^~~~~~~
In file included from extr_video.c:4:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
/usr/bin/ld: /tmp/ccl0Ztwt.o: undefined reference to symbol 'av_packet_free@@LIBAVCODEC_57'
//usr/lib/x86_64-linux-gnu/libavcodec.so.57: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status



root@ubuntu:~/coding-279# gcc -g -o extr_video extr_video.c `pkg-config --libs  -cflags  libavutil libavformat` 
Unknown option -cflags
extr_video.c: In function ‘h264_mp4toannexb’:
extr_video.c:190:13: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
             h264_extradata_to_annexb( fmt_ctx->streams[in->stream_index]->codec->extradata,
             ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from extr_video.c:4:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
extr_video.c:191:39: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
                                       fmt_ctx->streams[in->stream_index]->codec->extradata_size,
                                       ^~~~~~~
In file included from extr_video.c:4:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
     AVCodecContext *codec;
                     ^~~~~
/tmp/ccWbRNYx.o: In function `alloc_and_copy':
/home/xiaoming/coding-279/extr_video.c:30: undefined reference to `av_grow_packet'
/tmp/ccWbRNYx.o: In function `h264_extradata_to_annexb':
/home/xiaoming/coding-279/extr_video.c:75: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:77: undefined reference to `av_free'
/home/xiaoming/coding-279/extr_video.c:81: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:83: undefined reference to `av_free'
/home/xiaoming/coding-279/extr_video.c:86: undefined reference to `av_reallocp'
/home/xiaoming/coding-279/extr_video.c:105: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:110: undefined reference to `av_log'
/tmp/ccWbRNYx.o: In function `h264_mp4toannexb':
/home/xiaoming/coding-279/extr_video.c:135: undefined reference to `av_packet_alloc'
/home/xiaoming/coding-279/extr_video.c:226: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:244: undefined reference to `av_packet_free'
/tmp/ccWbRNYx.o: In function `main':
/home/xiaoming/coding-279/extr_video.c:270: undefined reference to `av_log_set_level'
/home/xiaoming/coding-279/extr_video.c:273: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:281: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:286: undefined reference to `av_register_all'
/home/xiaoming/coding-279/extr_video.c:290: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:295: undefined reference to `avformat_open_input'
/home/xiaoming/coding-279/extr_video.c:296: undefined reference to `av_strerror'
/home/xiaoming/coding-279/extr_video.c:297: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:305: undefined reference to `av_dump_format'
/home/xiaoming/coding-279/extr_video.c:308: undefined reference to `av_init_packet'
/home/xiaoming/coding-279/extr_video.c:313: undefined reference to `av_find_best_stream'
/home/xiaoming/coding-279/extr_video.c:315: undefined reference to `av_get_media_type_string'
/home/xiaoming/coding-279/extr_video.c:315: undefined reference to `av_log'
/home/xiaoming/coding-279/extr_video.c:342: undefined reference to `av_packet_unref'
/home/xiaoming/coding-279/extr_video.c:329: undefined reference to `av_read_frame'
/home/xiaoming/coding-279/extr_video.c:348: undefined reference to `avformat_close_input'
collect2: error: ld returned 1 exit status


0 回复 有任何疑惑可以回复我~
李超 2020-03-02 23:23:07

—libs 后面加一个参数 —cflags

0 回复 有任何疑惑可以回复我~
  • 提问者 慕圣0365731 #1
    试了两条命令都没有用:
    gcc -g -o extr_video extr_video.c `pkg-config --libs  -cflags  libavutil libavformat`
    
    
    gcc -g -o extr_video extr_video.c `pkg-config --libs  --cflags  libavutil libavformat`
    回复 有任何疑惑可以回复我~ 2020-03-02 23:55:01
  • 李超 #2
    是你的环境变量没配置或没配对,加入到课程QQ群来提问
    回复 有任何疑惑可以回复我~ 2020-03-03 12:31:54
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号