: undefined reference to `av_log' ffmpeg 编译例程出错 解决方法

出错状况:

使用SVN 获取ffmpeg 

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

安装成功。

编译简单例程:

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <stdio.h>

int main(int argc,char*argv[])
{
	av_register_all();
	return 0;
}
 
使用:gcc examp.c  -lavcodec -lavformat  -lavdevice  -lavutil   编译。

报N错。

/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:770: undefined reference to `av_buffer_alloc'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `ff_thread_get_format':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:822: undefined reference to `av_log'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `ff_thread_await_progress':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:502: undefined reference to `av_log'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `release_delayed_buffers':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:302: undefined reference to `av_frame_unref'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `submit_packet':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:336: undefined reference to `av_buffer_unref'
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:339: undefined reference to `av_buffer_ref'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `ff_thread_decode_frame':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:449: undefined reference to `av_frame_move_ref'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `update_context_from_user':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:271: undefined reference to `av_realloc'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `submit_packet':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:341: undefined reference to `av_fast_malloc'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `update_context_from_user':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:274: undefined reference to `av_free'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `submit_packet':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:298: undefined reference to `av_log'
/usr/local/lib/libavcodec.a(pthread_frame.o): In function `release_delayed_buffers':
/home/lnstree/ffmpegSrc/ffmpeg/libavcodec/pthread_frame.c:302: undefined reference to `av_frame_unref'
。。。。。

解决方法:

将make install 安装的 libavxxx.pc 文件移到默认pkg-config 目录中。

本机make install   libavxxxx.pc 文件 在/usr/local/lib/pkgconfig  

使用命令 cp /usr/local/lib/pkgconfig/*  /usr/share/pkgconfig/ 拷贝。


注:ffmpeg 源码 附带 例程。 make install 后 例程 在/usr/local/share/ffmpeg/examples 下。  里面有Makefile 文件。

在该目录下 make。(前提  所有 libavxxx.pc 已经移入默认目录/usr/share/pkconfig/)

make :

cc   decoding_encoding.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -lm -o decoding_encoding
cc   demuxing_decoding.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o demuxing_decoding
cc   filtering_video.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o filtering_video
cc   filtering_audio.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o filtering_audio
cc   metadata.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o metadata
cc   muxing.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -lm -o muxing
cc   resampling_audio.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -lm -o resampling_audio
cc   scaling_video.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o scaling_video
cc   transcode_aac.o  -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm    -o transcode_aac

然后 使用 该make 显示的编译参数


gcc example.c  -lavdevice -lavfilter -lavformat -lavcodec -ldl -lX11 -lasound -lSDL -lpthread -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -lz -lrt -lswresample -lswscale -lavutil -lm  

; D  偷懒,一大堆依赖看不懂,能用就行。

成功!!


参考网址:

http://blog.csdn.net/ajaxhe/article/details/9499815   有关pkg-config

http://www.myexception.cn/program/718423.html     

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值