本文介绍了ffmpeg - g ++的编译问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行一个程序,它使用ffmpeg库解码mp3文件。我使用以下选项编译程序:

I am trying to run a program which uses ffmpeg libraries to decode a mp3 file. I am using following options for compiling the program:

g++ -c play.cpp -o play.o
g++ -o play play.o -L/usr/local/lib -lavutil -lavcodec -lavformat -lavdevice \
                   -lavfilter -ldl -lasound -L/usr/lib -lSDL -lpthread -lz -lswscale -lm

但是当我链接时我gettign以下错误:

But while linking I am gettign following errors:

play.cpp:(.text+0x49): undefined reference to `av_dup_packet(AVPacket*)'
play.cpp:(.text+0x66): undefined reference to `av_malloc(unsigned int)'
play.cpp:(.text+0x324): undefined reference to `avcodec_decode_audio3(AVCodecContext*, short*, int*, AVPacket*)'
play.cpp:(.text+0x387): undefined reference to `av_free_packet(AVPacket*)'

..
这些报告的函数在我已经使用链接选项指定的libavcodec.a等中可用。
任何人都可以告诉我什么可能是错误在这里或建议如何调试这个?

and so on...These reported functions are available in the libavcodec.a etc. which i have already specified with the link options.Can anyone please tell me what could be wrong here or suggest how to approach debugging this?

推荐答案

这是您自己的程序,不是libav标准示例?我可能是错了,但如果是这样,你可能会忘记指定externC,同时包括libav标题:

Is this your own program, not the libav standard example? I might be wrong, but if so you probably could forget to specify extern "C" while including libav headers:

extern "C"
{
#include <avcodec.h>
#include <avformat.h>
}

这可能是问题'coz你试图用C ++编译器编译源代码, libav(ffmpeg)是使用C编译器编译的,所以你必须标记包含头的库由C编译器使用extern C编译。

This can be the problem 'coz you trying to compile sources with C++ compiler and libav (ffmpeg) is compiled using C compiler, so you must mark include headers for library as compiled by C compiler using extern C.

如果你做标记包括extern C已经,请从您的程序中发布一些代码块看看..

If you do mark includes as extern C already, please post some code chunk from your program to look at..

这篇关于ffmpeg - g ++的编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 00:42
查看更多