Linux,Eclipse C ++,如何将ffmpeg libs连接到您的项目?

时间:2011-02-21 19:12:37

标签: c++ c linux eclipse ffmpeg

所以我从svn下载了FFmpeg。编译并安装到系统中。在/ usr / local中创建./lib和./include。一个包含,一个包含* .a文件形式的库。

我下载了eclipse Helios for C ++并创建了一个新的简单项目。我将ffmpeg标头包含在我的C ++文件中。在C / C ++的项目属性中构建设置我声明了ffmpeg libs(声明了库搜索路径)

我编写了一些从头文件中调用函数的简单代码。

但对于我使用的所有ffmpeg函数,它给了我eclipse的错误,没有看到ffmpeg。

所以我想知道 - 如何将ffmpeg libs连接到我的项目(或者可能有任何方法将ffmpeg编译成.a并且它可以与.so一起工作)?

5 个答案:

答案 0 :(得分:3)

我在 ubuntu 12.04 上遇到了同样的问题,我通过这种方式编译ffmpeg和x264来修复它: 我删除了ffmpeg和x264的文件夹,然后在终端输入:

sudo apt-get remove ffmpeg x264
sudo apt-get autoremove

然后

sudo apt-get update
sudo apt-get upgrade

然后

sudo apt-get install make automake g++ bzip2 python unzip patch subversion ruby build-essential git-core checkinstall yasm texi2html libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvdpau-dev libvorbis-dev libvpx-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev

安装x264

sudo git clone git://git.videolan.org/x264.git
cd x264
sudo ./configure --enable-shared --prefix=/usr/local
sudo make
sudo make install
cd ..

安装libvpx

sudo wget http://webm.googlecode.com/files/libvpx-v0.9.7-p1.tar.bz2
sudo tar xvjf libvpx-v0.9.7-p1.tar.bz2
cd libvpx-v0.9.7-p1
sudo ./configure --enable-shared --prefix=/usr/local
sudo make
sudo make install
cd ..

检查/etc/ld.so.conf是否包含行/usr/lib/usr/local/lib。如果没有,则添加并保存

然后运行

sudo ldconfig

安装ffmpeg

sudo wget http://ffmpeg.org/releases/ffmpeg-0.8.10.tar.bz2
sudo tar xvjf ffmpeg-0.8.10.tar.bz2
cd ffmpeg-0.8.10
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-shared --prefix=/usr/local
sudo make
sudo make install
cd ..
sudo ldconfig
在项目中,您应该以这种方式包含标题:

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

在eclipse中你应该将ffmpeg库添加到你的项目中:avutil,avformat,avcodec,m,z ...转到project-&gt; properties-&gt; C / C ++ - &gt; Build-&gt; Settings- &gt; GCC C ++ - &gt;连接体 - &GT;库

我希望这对你有用

答案 1 :(得分:1)

您需要将它们与您的代码相关联。在make文件中使用-l和-L gcc命令行参数,或编辑Eclipse项目的属性(转到项目属性 - > C / C ++ - &gt; Build-&gt; Settings-&gt; GCC C ++ - &gt ;链接器 - &gt;库。

答案 2 :(得分:1)

如果您想要的包含和库分别位于/usr/local/include/usr/local/lib,那么您似乎可以使用包含和库路径(这些目录通常位于默认搜索路径中)。

确定在指定要链接到的库时未使用lib...,默认情况下会添加前缀,例如使用libabc.a只需在项目设置的库列表中指定abc

答案 3 :(得分:0)

如果您收到编译错误(不是链接器错误),请确保libav *文件夹位于/usr/local/include中,并且包含ffmpeg标头及其文件夹名称。

#include libavformat/avformat.h 
#include libavcodec/avcodec.h
// ...

您必须将/usr/local/include定义为包含目录,而不是内部的libav *文件夹。这是必需的,因为ffmpeg标题本身以这种方式引用其他标题。

答案 4 :(得分:0)

  1. 这取决于平台。
  2. 您必须使用所有正确的标志mingw /或cygwin正确配置ffmpeg库。你会得到.a文件可识别的文件。
  3. 正如littleadv所说,你必须配置ffmeg库的路径。在项目中 - &gt;构建属性 - 包括(ffmpeg folderand你的mingw / cygwin local include)和链接器设置avformat avcodec avfilter avdevice swscale postproc。
  4. 不要忘记在os中设置路径变量。 Eclipse拿这个。路径应该指向lib并包含/ local mingw / cygwin。
相关问题