系统环境:ubuntu 10.04
1. 安装解码库(若是windows 平台,下载ffmpeg sdk即可)
# apt-get install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
2.编译
# gcc -Wall decode_h264.c -o decode -lavcodec -lavformat -lavutil -lswscale
若没有指定链连库则会出现如下错误提示:
/tmp/ccJYTdYT.o: In function `nextFrame':
ipcam.c:(.text+0x3d0): undefined reference to `avcodec_decode_video'
ipcam.c:(.text+0x490): undefined reference to `sws_getContext'
ipcam.c:(.text+0x4e0): undefined reference to `sws_scale'
/tmp/ccJYTdYT.o: In function `main':
ipcam.c:(.text+0x590): undefined reference to `avcodec_init'
ipcam.c:(.text+0x595): undefined reference to `avcodec_register_all'
ipcam.c:(.text+0x5a1): undefined reference to `avcodec_find_decoder'
ipcam.c:(.text+0x5be): undefined reference to `avcodec_alloc_context'
ipcam.c:(.text+0x5ed): undefined reference to `avcodec_open'
ipcam.c:(.text+0x600): undefined reference to `avcodec_alloc_frame'
ipcam.c:(.text+0x65c): undefined reference to `avcodec_alloc_frame'
ipcam.c:(.text+0x67d): undefined reference to `avpicture_get_size'
ipcam.c:(.text+0x68d): undefined reference to `av_malloc'
ipcam.c:(.text+0x6c1): undefined reference to `avpicture_fill'
ipcam.c:(.text+0x6f9): undefined reference to `avcodec_close'
ipcam.c:(.text+0x706): undefined reference to `av_free'
ipcam.c:(.text+0x713): undefined reference to `av_free'
collect2: ld returned 1 exit status
3.源代码
阅读(4500) | 评论(0) | 转发(0) |