FFMpeg sample program

2019-05-03 12:05发布

I am currently learning ffmpeg tutorial of Martin Bohme Tutorial Here

and I want to compile an ffmpeg sample program using Code Block IDE but, it can't

#include <stdio.h>
#include <stdlib.h>

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

int main(int argc, char *argv[])
{
av_register_all();

    return 0;
}

Please help me. How to compile it. I am using Linux (Ubuntu)

3条回答
Fickle 薄情
2楼-- · 2019-05-03 12:50

You have to tell the compiler where the header and library files are. This is done by the -I flag to tell which directories contain header files, and -L to tell which directories contains libraries. You will also need -l to tell which libraries to link with.

The flags can be used like this:

$ g++ -I/path/to/headers myprogram.cpp -L/path/to/libraries -lthelibrary

A note about libraries: On Linux (and UNIX systems) they are files with names that start with "lib" and end with the extension ".a" or ".so". When specifying the library with the -l flag you do not write those. So for a library file "libfoo.a", you only use -lfoo to link with it.

For more information about the options of gcc and g++, see http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html.

Edit: For an IDE like Code::Blocks there most likely is some project setting where you can add include and library directories and link libraries. Check the "Project" menu for a "Settings" or "Properties" alternative.

Edit2: See for example this FAQ where to find linker settings in Code::Blocks, the pre-processor settings should be close by.

查看更多
混吃等死
3楼-- · 2019-05-03 12:54
神经病院院长
4楼-- · 2019-05-03 13:01

you can try following command to compile in Linux.

gss <program-name.c> 
查看更多
登录 后发表回答