ffmpeg c++引用C头文件问题

1, bug

[root@localhost demo]# gcc -m32   test.cpp -g -o encode_video.out -I /usr/local/include -I/usr/local/ffmpeg/include -L /usr/local/ffmpeg/lib/ -lavformat -lavcodec -lavutil  -lpthread -lm -ldl
/tmp/cc8sUfgi.o:在函数‘encode(AVCodecContext*, AVFrame*, AVPacket*, _IO_FILE*)’中:
/home/sbyygyfd/svac_test/demo/test.cpp:207:对‘avcodec_send_frame(AVCodecContext*, AVFrame const*)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:214:对‘avcodec_receive_packet(AVCodecContext*, AVPacket*)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:224:对‘av_packet_unref(AVPacket*)’未定义的引用
/tmp/cc8sUfgi.o:在函数‘main’中:
/home/sbyygyfd/svac_test/demo/test.cpp:804:对‘avcodec_find_encoder_by_name(char const*)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:810:对‘avcodec_alloc_context3(AVCodec const*)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:816:对‘av_packet_alloc()’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:840:对‘av_opt_set(void*, char const*, char const*, int)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:843:对‘avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:855:对‘av_frame_alloc()’未定义的引用
/home/sbyygyfd/svac_test/demo/test.cpp:864:对‘av_frame_get_buffer(AVFrame*, int)’未定义的引用

/tmp/cc8sUfgi.o:在函数‘decode(unsigned char*, int, unsigned char, int)’中:


解决方法:  添加 

extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
}

猜你喜欢

转载自blog.csdn.net/weixin_40592935/article/details/80432868