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

StackOverflow https://stackoverflow.com/questions/1636447

  •  06-07-2019
  •  | 
  •  

Question

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)

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top