编译ffmpeg例程时,报错:undefined reference

编译ffmpeg例程,报了未定义错误:

main.cpp:(.text+0x3a): undefined reference to avcodec_send_frame(AVCodecContext*, AVFrame const*)'
main.cpp:(.text+0x8c): undefined reference to
av_packet_unref(AVPacket*)’
main.cpp:(.text+0x97): undefined reference to avcodec_receive_packet(AVCodecContext*, AVPacket*)'
build/src/main.cpp.o: In function
main’:
main.cpp:(.text.startup+0x4b): undefined reference to avcodec_register_all()'
main.cpp:(.text.startup+0x53): undefined reference to
avcodec_find_encoder_by_name(char const*)’
main.cpp:(.text.startup+0x5d): undefined reference to avcodec_find_encoder(AVCodecID)'
main.cpp:(.text.startup+0x71): undefined reference to
avcodec_alloc_context3(AVCodec const*)’
main.cpp:(.text.startup+0x84): undefined reference to av_packet_alloc()'
main.cpp:(.text.startup+0xf9): undefined reference to
avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)’
main.cpp:(.text.startup+0x11f): undefined reference to av_frame_alloc()'
main.cpp:(.text.startup+0x154): undefined reference to
av_frame_get_buffer(AVFrame*, int)’
main.cpp:(.text.startup+0x182): undefined reference to av_frame_make_writable(AVFrame*)'
main.cpp:(.text.startup+0x2f0): undefined reference to
avcodec_free_context(AVCodecContext**)’
main.cpp:(.text.startup+0x2fa): undefined reference to av_frame_free(AVFrame**)'
main.cpp:(.text.startup+0x304): undefined reference to
av_packet_free(AVPacket**)’
main.cpp:(.text.startup+0x3aa): undefined reference to `av_opt_set(void*, char const*, char const*, int)’

原因:
ffmpeg是纯C的库,头文件没有做好C++调用的准备
用extern “C”{}套住ffmpeg头文件,用C语言的编译规则来编译ffmpeg代码,就可以了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值