Berschi
Berschi

Reputation: 2665

Load an extern C-library into an existing C++-Project (f.e. ffmpeg/libavcodec - step by step)

I really have big problems with importing an extern C-Library to my existing C++-Project. I want to import libavcodec from the FFmpeg-Project, so I downloaded the latest source-code-release.
What do I have to do now? Do I have to compile FFmpeg first or can I import it just like that? A really simple step-by-step manual would be awesome!
(I found tutorials how to use libavcodec when it's imported, so this is not necessary... I didn't found some to import it)

Upvotes: 1

Views: 1154

Answers (2)

funkaoshi
funkaoshi

Reputation: 11

You need to build your external library. This will produce a library file you will use when building your program. You include the library during the linking process when compiling your program. You will also need to "#include" the headers you want to use in your own source. You will probably need to tell the compiler where the FFmpeg headers are located, using the "-I" flag in g++, and where the library is located using the "-L" flag.

Upvotes: 1

quamrana
quamrana

Reputation: 39404

To include a source code library into your existing project you have a number of options:

  • Compile to a static library

  • Compile to a dynamic library

  • Compile to object files

So, yes, you do need to compile their source code, and you need to change your toolchain to include the results into your program.

Upvotes: 2

Related Questions